Run-time error '1004' : Method 'Range' of object'_Global' failed; SIMPLE COPY AND PASTE

别等时光非礼了梦想. 提交于 2019-12-02 21:01:24

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!