I have data in each cell of "C5:E7"
Error code:
Quote"Application-defined or object-defined error"
I have data in each cell of "C5:E7"
Error code:
Quote"Application-defined or object-defined error"
Re: Print out a simple range
rng1 and rng2 are Range Objects that you haven't qualified so they pertain to the active sheet at the time of initialization.
This is what I believe you are trying to achieve:
Private Sub CommandButton_Click()
Dim rng1 As Range, rng2 As Range
string1 = "C5:E7" string2 = "C12:E14"
Set rng1 = Sheets(2).Range(string1)
Set rng2 = Sheets(1).Range(string2)
rng2.Value = rng1.Value
End Sub
also, this:
will never work.
At this point rng1 is already a range object, so you wouldn't qualify it with a sheet object or refer to it using the Range() method.
Don’t have an account yet? Register yourself now and be a part of our community!