maabadi
Well-known Member
- Joined
- Oct 22, 2012
- Messages
- 2,681
- Office Version
- 2019
- 2016
- Platform
- Windows
I want to set myrange based on cell value, but when run my macro. I see runtime error 91.
object not defined or set block variable
Sub SetRangeforPrint()
Dim MyRange As Range
Dim ws As Worksheet
Dim Lastrow As Long
If Range("B65").Value <> "" Then
Lastrow = Range("B65").Value * 34 + 6
Debug.Print Lastrow
MyRange = Range("A1:K" & Lastrow)
Debug.Print MyRange
End If
End Sub
object not defined or set block variable
Sub SetRangeforPrint()
Dim MyRange As Range
Dim ws As Worksheet
Dim Lastrow As Long
If Range("B65").Value <> "" Then
Lastrow = Range("B65").Value * 34 + 6
Debug.Print Lastrow
MyRange = Range("A1:K" & Lastrow)
Debug.Print MyRange
End If
End Sub