"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

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
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,215,809
Messages
6,127,010
Members
449,351
Latest member
Sylvine

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