"Expected =" when trying to clear range

Martunis99

New Member
Joined
Aug 16, 2021
Messages
19
Office Version
  1. 2016
Platform
  1. Windows
Hi guys,

I am getting an error of "Expected =" when trying to clear a range.

My code is:

Rich (BB code):
ThisWorkbook.Worksheets("Ind Output").Range(IO.Offset(2, -1).Address(0, 0), Range(IO.Offset(2, -1).Address(0, 0)).End(xlDown).End(xlToRight)).ClearContents

But the following section is returning this error:

Rich (BB code):
ThisWorkbook.Worksheets("Ind Output").Range(IO.Offset(2, -1).Address(0, 0), Range(IO.Offset(2, -1).Address(0, 0)).End(xlDown).End(xlToRight))

I am not too sure what I am doing wrong?

Thank you for your help!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi,​
'cause obviously you forgot a worksheet reference !​
Expecting IO is defined and matches the great Logic as after all we are not on some mind readers forum :​
VBA Code:
    With ThisWorkbook.Worksheets("Ind Output")
        .Range(IO.Offset(2, -1).Address, .Range(IO.Offset(2, -1).Address).End(xlDown).End(xlToRight)).ClearContents
    End With
 
Upvote 0
Solution
Oh man, you are spot on Marc L! Didn't even remember into looking at the second Range. You are totally right, I can't expect VBA to guess to which Range I am referring to.

Thank you so much for your help and I apologize for the hassle!
 
Upvote 0

Forum statistics

Threads
1,216,375
Messages
6,130,245
Members
449,568
Latest member
mwl_y

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top