|
▼Yoshi さん:
おはようございます。
>Sub データの集計()
>Dim i As Long, k As Long, LstRow As Long
>Dim Dsum As Long, ws As Worksheet
>
>For i = 4 To Sheets.Count
If Sheets(i) is Sheets("sheet1") Then Exit for
'又は、
If Sheets(i).name=Sheets("sheet1").name Then Exit for
> With Sheets(i)
> LstRow = .Range("D" & Rows.Count).End(xlUp).Row
> For k = 2 To LstRow
> Dsum = Dsum + .Range("D" & k)
> Next k
> End With
> Sheets("sheet2").Range("A" & Rows.Count).End(xlUp).Offset(1) = Sheets(i).Name
> Sheets("sheet2").Range("B" & Rows.Count).End(xlUp).Offset(1) = Dsum
>Next i
>End Sub
|
|