Im writing a code and I'm kinda of new to this. I keep getting a compile error on my macro code, a compile error that the sub or function is not defined. I tried to use to vba menu < tools < reference but I cannot click on it. Any suggestions? Below is the macro code I am trying to run
我在写代码,我对这个有点陌生。我在宏代码上不断得到一个编译错误,一个未定义子或函数的编译错误。我尝试使用vba菜单< tools < reference,但是我不能点击它。有什么建议吗?下面是我要运行的宏代码
Sub Update()
'
'
Application.ScreenUpdating = True
Dim copysheet As Worksheet
Dim pastesheet As Worksheet
Set copysheet = Worksheets("Daily Sheet")
Set pastehseet = Worksheets("Raw Data")
copysheet.Range("G5").Copy
Sheet("Raw Data").Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSpecial _
Paste:=xlPasteValue, Operation:=xlNone, Skipblanks_:=False, Transpose:=False
copysheet.Range("G7").Copy
Sheet("Raw Data").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial _
Paste:=xlPasteValue, Operation:=xlNone, Skipblanks_:=False, Transpose:=False
copysheet.Range("G14").Copy
Sheet("Raw Data").Range("C" & Rows.Count).End(xlUp).Offset(1).PasteSpecial _
Paste:=xlPasteValue, Operation:=xlNone, Skipblanks_:=False, Transpose:=False
copysheet.Range("G9").Copy
Sheet("Raw Data").Range("D" & Rows.Count).End(xlUp).Offset(1).PasteSpecial _
Paste:=xlPasteValue, Operation:=xlNone, Skipblanks_:=False, Transpose:=False
copysheet.Range("G11").Copy
Sheet("Raw Data").Range("G" & Rows.Count).End(xlUp).Offset(1).PasteSpecial _
Paste:=xlPasteValue, Operation:=xlNone, Skipblanks_:=False, Transpose:=False
copysheet.Range("G13").Copy
Sheet("Raw Data").Range("H" & Rows.Count).End(xlUp).Offset(1).PasteSpecial _
Paste:=xlPasteValue, Operation:=xlNone, Skipblanks_:=False, Transpose:=False
Sheets("Daily Sheet").Range("G5:G14").Select.ClearContents
Sheets("Daily Sheet").Range("K9").Select
End Sub
1 个解决方案
#1
1
Dim copysheet As Worksheet
Dim pastesheet As Worksheet
Set copysheet = Worksheets("Daily Sheet")
Set pastesheet = Worksheets("Raw Data")
copysheet.Range("G5").Copy
Sheets("Raw Data").Range("A" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G7").Copy
Sheets("Raw Data").Range("B" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G14").Copy
Sheets("Raw Data").Range("C" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G9").Copy
Sheets("Raw Data").Range("D" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G11").Copy
Sheets("Raw Data").Range("G" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G13").Copy
Sheets("Raw Data").Range("H" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Daily Sheet").Range("G5:G14").clear
Worksheets("Daily Sheet").Range("K9").Select
Appears to do what you want.
似乎做你想做的。
The issues I found were:
我发现的问题是:
The use of sheet - not sheets (that explains the error you were getting, as it thought sheet was another macro or similar
表的使用——而不是表(这解释了您所得到的错误,因为它认为表是另一个宏或类似的
Similarly, you had missed the x off of the end of xlvalues on the paste specials.
类似地,您已经错过了粘贴专门性的xlvalues末尾的x。
Finally, you need to use Worksheets(ws.name) for the selection at the end.
最后,您需要使用工作表(ws.name)作为最后的选择。
Hope that this helps
希望这对您有所帮助
#1
1
Dim copysheet As Worksheet
Dim pastesheet As Worksheet
Set copysheet = Worksheets("Daily Sheet")
Set pastesheet = Worksheets("Raw Data")
copysheet.Range("G5").Copy
Sheets("Raw Data").Range("A" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G7").Copy
Sheets("Raw Data").Range("B" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G14").Copy
Sheets("Raw Data").Range("C" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G9").Copy
Sheets("Raw Data").Range("D" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G11").Copy
Sheets("Raw Data").Range("G" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
copysheet.Range("G13").Copy
Sheets("Raw Data").Range("H" & Rows.Count).End(xlUp).offset(1).PasteSpecial Paste:=xlPasteValues
Sheets("Daily Sheet").Range("G5:G14").clear
Worksheets("Daily Sheet").Range("K9").Select
Appears to do what you want.
似乎做你想做的。
The issues I found were:
我发现的问题是:
The use of sheet - not sheets (that explains the error you were getting, as it thought sheet was another macro or similar
表的使用——而不是表(这解释了您所得到的错误,因为它认为表是另一个宏或类似的
Similarly, you had missed the x off of the end of xlvalues on the paste specials.
类似地,您已经错过了粘贴专门性的xlvalues末尾的x。
Finally, you need to use Worksheets(ws.name) for the selection at the end.
最后,您需要使用工作表(ws.name)作为最后的选择。
Hope that this helps
希望这对您有所帮助