Method Range of Object Global failed
May 2, 2012 3:49 AM Subscribe
I'm starting to write some Excel-VBA Macros, but it seems I don't get some basic things. I tried this simple code:
Sub Macro1()
Dim MyRange As Range
Set MyRange = Worksheets("Sheet1").Range("A1")
MsgBox (MyRange)
'MyRange.Copy
Range("MyRange").Copy
Range("A2").Select
ActiveSheet.Paste
End Sub
It displays the content of the cell and copies it with MyRange.Copy, however if I use Range("MyRange").Copy instead I get a Method Range of Object Global failed. Why is this so?
posted by SweetLiesOfBokonon to computers & internet (4 answers total) 4 users marked this as a favorite
On the line below it: "A2" is being passed as a string (of cells names). Note that you didn't need to declare an "A2" range beforehand to use it.
posted by unixrat at 4:54 AM on May 2, 2012