Hello I have a weird thing going on with some practice code I'm trying. I am trying to create a code that copies the value of a cell, that has a range in it (@Rick Rothstein for helping with that). That works. I then want to use that value (the range) and select said range in a different worksheet. The below code does that.
However, the code below is Actually what I need, and now the code throws an error at the select function? Why is it doing that??? The only think I changed was the order of the sheets? Also, does anyone know how to fix this???
Just FYI the cell in A1 on both Sheet 2 and Sheet 1 are exactly the same
VBA Code:
Public Sub Blah()
Dim rng As Range
'MsgBox Cells(2, 1).Value
Sheet2.Activate
Set rng = Range(Sheet2.Cells(1, 1).Value)
Sheet1.Activate
rng.Select
rng.Interior.Color = RGB(255, 0, 0)
'MsgBox rng
End Sub
However, the code below is Actually what I need, and now the code throws an error at the select function? Why is it doing that??? The only think I changed was the order of the sheets? Also, does anyone know how to fix this???
VBA Code:
Public Sub Blah()
Dim rng As Range
'MsgBox Cells(2, 1).Value
Sheet1.Activate
Set rng = Range(Sheet1.Cells(1, 1).Value)
Sheet2.Activate
rng.Select
rng.Interior.Color = RGB(255, 0, 0)
'MsgBox rng
End Sub
Just FYI the cell in A1 on both Sheet 2 and Sheet 1 are exactly the same