问题
I'm just trying to do a simple cut and paste to shift ranges in F:G to an unoccupied cell in D
but I keep getting that error message. My codes are in the Modules and I don't know what I'm doing wrong! Completely new to VBA. Highlighted portion: Range("F" & RowNum & ":G" & RowNum).Select
Sub MoveCells(RowNum as Integer)
Range(“F” & RowNum & ":G" & RowNum).Select
Selection.Cut
Range(“D” & RowNum).Select
ActiveSheet.Paste
End Sub
回答1:
Range(“F” & RowNum & ":G" & RowNum).Select
^ ^ ^ ^
| | | |
Chr(147) Chr(34)
The 'quotation marks' around F
are character 147. To denote a string value you have to use character 34, like the ones around :G
This usually happens when copy/pasting code from a website. Delete the quotation marks and re-write them manually to solve the issue.
来源:https://stackoverflow.com/questions/35742314/run-time-error-1004-method-range-of-object-global-failed-simple-copy-an