GOOGLE了一下好像常常有這種情況
跑到 ".Range(Cells(j, 1), Cells(j, 23)).Copy"
就發生錯誤了
我一直抓不出問題@@
我單獨抓出錯誤那行執行還可以跑
不知是哪邊出錯了
麻煩各位大大幫幫忙 謝謝 : )- Sub CommandButton1_Click()
- For i = 5 To 10
-
- MsgBox "Sheets: " & i
-
- With Worksheets(i)
-
- row_from = .Range("A35536").End(xlUp).row
-
- For j = 2 To row_from
-
- If .Range("S" & j) <> 0 Then
- MsgBox "欄位: " & j
- row_to = Worksheets(4).Range("A35536").End(xlUp).row + 1
- .Range(Cells(j, 1), Cells(j, 23)).Copy <------錯誤1004
- Worksheets(4).Cells(row_to, 1).PasteSpecial Paste:=xlPasteAll
- .Range(Cells(j, 1), Cells(j, 23)).Interior.Color = 65535
- End If
- Next
- End With
- Next
-
- End Sub
複製代碼 |