|
たびたびお世話になっています。
複数のシートをひとつにまとめたいのですが
構文エラーが出てしまいます。
どなたか教えていただけますでしょうか?
よろしくお願いいたします。
Sub test4()
Dim WS_TOTAL As Worksheet
Dim WS_1 As Worksheet
Dim WS_2 As Worksheet
Dim WS_3 As Worksheet
Dim WS_4 As Worksheet
Dim WS_5 As Worksheet
Dim WS_6 As Worksheet
Set WS_TOTAL = Worksheets("シート作成")
Set WS_1 = Worksheets("Sheet1")
Set WS_2 = Worksheets("Sheet2")
Set WS_3 = Worksheets("Sheet3")
Set WS_4 = Worksheets("Sheet4")
Set WS_5 = Worksheets("Sheet5")
Set WS_6 = Worksheets("Sheet6")
If WS_TOTAL.Cells(Rows.Count, 1).End(xlUp).Row > 3 Then
WS_TOTAL.Rows("1:" & Cells(Rows.Count, 1).End(xlUp).Row).ClearContents
End If
If WS_1.Cells(Rows.Count, 1).End(xlUp).Row > 3 Then
WS_1.Rows("1:" & WS_1.Cells(Rows.Count, 1).End(xlUp).Row).Copy _
WS_TOTAL.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
If WS_2.Cells(Rows.Count, 1).End(xlUp).Row > 3 Then
WS_2.Rows("1:" & WS_2.Cells(Rows.Count, 1).End(xlUp).Row).Copy _
WS_TOTAL.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
If WS_3.Cells(Rows.Count, 1).End(xlUp).Row > 3 Then
WS_3.Rows("1:" & WS_3.Cells(Rows.Count, 1).End(xlUp).Row).Copy
↓が構文エラーと出ます。
WS_TOTAL.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
If WS_4.Cells(Rows.Count, 1).End(xlUp).Row > 3 Then
WS_4.Rows("1:" & WS_4.Cells(Rows.Count, 1).End(xlUp).Row).Copy _
WS_TOTAL.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
If WS_5.Cells(Rows.Count, 1).End(xlUp).Row > 3 Then
WS_5.Rows("1:" & WS_5.Cells(Rows.Count, 1).End(xlUp).Row).Copy _
WS_TOTAL.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
If WS_6.Cells(Rows.Count, 1).End(xlUp).Row > 3 Then
WS_6.Rows("1:" & WS_6.Cells(Rows.Count, 1).End(xlUp).Row).Copy _
WS_TOTAL.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
End If
End If
End If
End If
End If
End If
Set WS_TOTAL = Nothing
Set WS_1 = Nothing
Set WS_2 = Nothing
Set WS_3 = Nothing
Set WS_4 = Nothing
Set WS_5 = Nothing
Set WS_6 = Nothing
End Sub
|
|