|
发表于 2018-7-17 16:04
来自手机
|
显示全部楼层
本帖最后由 hasyh2008 于 2018-7-18 08:08 编辑
jjmysjg 发表于 2018-7-17 14:33
如果各个字表的命名不规则,比如是一、二、三等,代码能改改吗
Sub 汇总()
Dim x%, y%, str As String
For x = 3 To Range("A" & Rows.Count).End(xlUp).Row
For y = 1 To sheets.count-1
str = Range("A" & x).Value
Cells(x, y + 2) = Application.VLookup(str, Sheets(y ).Range("A:C"), 3, False)
If Cells(x, y + 2).Text = "#N/A" Then
Cells(x, y + 2).Value = 0
End If
Range("O" & x) = WorksheetFunction.Sum(Range("C" & x).Resize(1, 12))
Next y
Next x
End Sub
Sub 清除()
Range("C3:O" & Rows.Count).ClearContents
End Sub
Sub 提取物资名称()
Dim i%
For i = 1 To sheets.count
Sheets(i).Select
Sheets(i).Range("A3:B" & Sheets(i).Range("B" & Rows.Count).End(xlUp).Row).Select
Selection.Copy Sheet13.Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
Next i
Sheet13.Select
Range("A2:B" & Range("B" & Rows.Count).End(xlUp).Row).RemoveDuplicates Columns:=Array(1, 2), Header:=xlYes
End Sub |
评分
-
1
查看全部评分
-
|