Excel Run-time error 91: Object variable or With block variable not set
Hi,
I am trying to set the range value in excel macro using a VBA. But after I run the macro, I get the following error:
Run-time error '91': Object variable or With block variable not set.
I am using a VBA range data type. My macro looks like this:
Dim LastCellPosition As Range
LastCellPosition = Nothing
Run-time error 91: 'Object variable or With block variable not set' relates to the data type used in this case.
"Range" is an object data type. You need to use "Set" to assign an object reference to a variable.
Your VBA macro code should be:
Dim LastCellPosition As Range
Set LastCellPosition = Nothing
1 answer