1:新建个sheet(如图ALL,里面数据是空的)
2右击查看代码
复制代码进去,运行(F5)
Sub hb()
Dim bt, i, r, c, n, first As Long
bt = 1 '表头行数,多行改为对应数值
Cells.Clear
For i = 1 To Sheets.Count
If Sheets(i).Name <> ActiveSheet.Name Then
If first = 0 Then
c = Sheets(i).Cells(1, Columns.Count).End(xlToLeft).Column
Sheets(i).Range("A1").Resize(bt, c).Copy Range("A1")
n = bt + 1: first = 1
End If
r = Sheets(i).Cells(Rows.Count, "A").End(xlUp).Row
Sheets(i).Range("A" & bt + 1).Resize(r - 1, c).Copy Range("A" & n)
n = n + r - bt
End If
Next
End Sub
运行后,数据进来如图
复制A列到E, 选择E列,数据->删除重复项
选择F2, =SUMIF(A:A,E2,B:B)
下拉就得到了:
网友评论