0

I keep on getting the following error in VBA

"Object Variable or With Block Variable not set"

I have no idea why

My code is

Private Sub Worksheet_Calculate()
    Dim RNG As Range
    RNG = Sheet1.Range("C15:D55,G11,G12,G15,G18,G19")
End Sub

The Sheet CodeName is correct.

Anyone have any ideas? Thanks

Community
  • 1
  • 1
Yair Halberstadt
  • 5,733
  • 28
  • 60

1 Answers1

0

A Range type is an Object type, and must be assigned to with the Set statement:

Private Sub Worksheet_Calculate()
    Dim RNG As Range
    Set RNG = Sheet1.Range("C15:D55,G11,G12,G15,G18,G19")
End Sub
ThunderFrame
  • 9,352
  • 2
  • 29
  • 60