我到处都找遍了,只是没办法让它运行。我是VBA的新手,所以如果可能的话,我会很乐意得到一些建议或帮助。
所以我录制的宏是:
Range("C133:C134").Select
Selection.Copy
Sheets("AVGs").Select
Range("C28").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True我的目标是选择和复制随机单元,特别是在不同工作表上的随机单元格中。
我走了这么远:
Selection.Copy
Sheets("AVGs").Select
Set x = Application.InputBox(prompt:="Click in the column to copy to", Type:=8)
Range("x").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, Transpose:=True但我只是得到和错误和调试器显示错误在Range("x").Select .
发布于 2013-10-15 13:59:13
根据InputBoxes上的这个页面..。
http://msdn.microsoft.com/en-us/library/office/aa195768(v=office.11).aspx
类型8表示输入框应该返回范围对象。
8 A cell reference, as a Range object
如果是这样的话,你只需要做
x.Select
以选择用户指示的范围。如果您使用type = 2,那么您将使用Range(x).Select
之后,宏中的最后一行与过程中的行相同,因此应该关闭并运行。
编辑,新代码:
Set x = Application.InputBox(prompt:="Set cell to copy", Type:=8)
x.Select
Selection.Copy
Sheets("AVGs").Select
Set y = Application.InputBox(prompt:="Set cell to paste", Type:=8)
y.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=Truehttps://stackoverflow.com/questions/19382097
复制相似问题