I try to write, in VBA, a macro that copies tables (colors, formats etc.) from the sheet for each day (Monday, Tuesday, Wednesday, Thursday and Friday) and pastes to sheets (262 sheets) for the same day.
(我尝试在VBA中编写一个宏,该宏每天(每天,周一,周二,周三,周四和周五)从工作表中复制表格(颜色,格式等),并粘贴到同一天的工作表(262张)中。)
(Monday - Monday etc.) Sheets names I have in sheet "Data". ((星期一-星期一等。)工作表名称我在工作表“数据”中拥有的名称。)
But I got this error: Run-time error '1004': Method PasteSpecial class Range Failure.
(但是我遇到了以下错误:运行时错误'1004':方法PasteSpecial类范围失败。)
Thank you for your help!
(谢谢您的帮助!)
This is my VBA macro:
(这是我的VBA宏:)
Sub copy_paste()
For i = 1 To 262
If 1 = i Mod 5 Then
Worksheets("wednesday").Activate
Cells.Select
Application.CutCopyMode = False
Selection.Copy
' This is the problem part of code (said Debugger)
Sheets(Worksheets("Data").Cells(i, 2).Value).Range("A1").PasteSpecial _
Paste:=x1PasteAllUsingSourceTheme, Operation:=x1None _
, SkipBlanks:=False, Transpose:=False
End If
If 2 = i Mod 5 Then
Sheets("thursday").Select
Application.CutCopyMode = False
Selection.Copy
Sheets(Worksheets("Data").Cells(i, 2).Value).Range("A1").PasteSpecial _
Paste:=x1PasteAllUsingSourceTheme, Operation:=x1None _
, SkipBlanks:=False, Transpose:=False
End If
If 3 = i Mod 5 Then
Sheets("friday").Select
Application.CutCopyMode = False
Selection.Copy
Sheets(Worksheets("Data").Cells(i, 2).Value).Range("A1").PasteSpecial _
Paste:=x1PasteAllUsingSourceTheme, Operation:=x1None _
, SkipBlanks:=False, Transpose:=False
End If
If 4 = i Mod 5 Then
Sheets("monday").Select
Application.CutCopyMode = False
Selection.Copy
Sheets(Worksheets("Data").Cells(i, 2).Value).Range("A1").PasteSpecial _
Paste:=x1PasteAllUsingSourceTheme, Operation:=x1None _
, SkipBlanks:=False, Transpose:=False
End If
If 0 = i Mod 5 Then
Sheets("tuesday").Select
Application.CutCopyMode = False
Selection.Copy
Sheets(Worksheets("Data").Cells(i, 2).Value).Range("A1").PasteSpecial _
Paste:=x1PasteAllUsingSourceTheme, Operation:=x1None _
, SkipBlanks:=False, Transpose:=False
End If
Next i
End Sub
(结束子)
ask by Jan Beran translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…