StackOverflow和VBA新手在这里发帖#1。我找不到关于这个的另一篇文章(但搜索框和我相处得不好)
我在Excel中编写了一个必须
的宏问题是它在我的计算机上运行正常但在我朋友的计算机上的第一个复制命令崩溃了。
这是我的代码,直到它崩溃的With / EndWith。 (它在With行上崩溃,要求它复制,然后才能进入我的取消隐藏命令。)
问题:
其他?
' Dimensioning for variables
Dim HO_File As String
Dim Local_File As String
Dim Band_1 As String
Dim Band_2 As String
Dim Band_3 As String
Dim Band_4 As String
Dim Band_5 As String
Dim i1 As Long
' Set the values of all my variables
HO_File = [HO_Wkbk_Name] ' This is the name of the head office workbook
Local_File = [This_Wkbk_Name]
Band_1 = [Band_1_Sheet]
Band_2 = [Band_2_Sheet]
Band_3 = [Band_3_Sheet]
Band_4 = [Band_4_Sheet]
Band_5 = [Band_5_Sheet]
' Unhide all relevant worksheets in this workbook
' Copy the headers from the Band_1 sheet from the HO file
' to the orange section of the "Copy" sheet of the local workbook
With Workbooks(HO_File).Sheets(Band_1).Range("C19:W22").Copy 'This is the line that crashes
Workbooks(Local_File).Sheets("Copy").Visible = True
Workbooks(Local_File).Sheets("MacroCalcs").Visible = True
Workbooks(Local_File).Sheets("Calculations").Visible = True
Workbooks(Local_File).Sheets("Pivot Data").Visible = True
Workbooks(Local_File).Sheets("Copy").Select
Sheets("Copy").Range("A15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
如果我在发帖时犯了错误,请道歉。现在已经很晚了,大脑也被炒了。请告诉我。
提前谢谢你。
以斯帖。