I wrote some functional VBA:
Sheets("Src").Range("A2:A9").Copy Destination:=Sheets("Dest").Range("A2")
I want to extract the source range into a variable for flexibility.
SrcRange = Sheets("Src").Range("A2:A9")
SrcRange.Copy Destination:=Sheets("Dest").Range("A2")
However, this does not work. Which SrcRange should be darkened? Is the first line even correct?
I tried Dimming SrcRange as Range and it gave me
Runtime error 91: Object Variable or With block variable not set
I am not very familiar with the language, and the documentation left me wanting (I could not find the return type for calling the Tables (index), this was the closest I found). When I click Record Macro, I perform some actions and stop, the macro body remains empty.
Can anyone shed some light on how to use SrcRange as a variable?
source
share