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
0
give a positive ratinggive a negative rating
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
Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2024 AnswerTabsTermsContact us