运行时错误“1004":对象“_Global"的方法“范围"失败;简单的复制和粘贴 [英] Run-time error '1004' : Method 'Range' of object'_Global' failed; SIMPLE COPY AND PASTE
问题描述
我只是试图做一个简单的剪切和粘贴来将 F:G 中的范围移动到 D
中的一个未占用的单元格,但我不断收到该错误消息.我的代码在模块中,我不知道我做错了什么!对 VBA 完全陌生.高亮部分:Range("F" & RowNum & ":G" & RowNum).Select
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
推荐答案
Range("F" & RowNum & ":G" & RowNum).Select
^ ^ ^ ^
| | | |
Chr(147) Chr(34)
F
周围的引号"是字符 147.要表示字符串值,您必须使用字符 34,就像 :G
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.
这篇关于运行时错误“1004":对象“_Global"的方法“范围"失败;简单的复制和粘贴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!