Clear Contents of 2nd Column to Last Column of Data

bs0d

Well-known Member
Joined
Dec 29, 2006
Messages
622
What's the most efficient code to clear the contents of all row data from the 2nd column through the last column?

This is what I use to clear everything:
Code:
With Sheet("Sheet1").Cells
        .ClearContents
End With

But how can I do the same and exclude the first column?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Try:
Code:
With Sheets("Sheet1")
   .Range("B1", .cells(rows.count, columns.count)).ClearContents
End With
 
Upvote 0
What's the most efficient code to clear the contents of all row data from the 2nd column through the last column?

This is what I use to clear everything:
Code:
With Sheet("Sheet1").Cells
        .ClearContents
End With
But how can I do the same and exclude the first column?
Try it this way...

Sheets("Sheet1").Columns("B").Resize(, Columns.Count - 1).ClearContents
 
Upvote 0
I suspect Rick's solution would be most efficient being a single line of code? Although but both use .ClearContents to erase the data. I appreciate the feedback, thanks
 
Upvote 0

Forum statistics

Threads
1,214,913
Messages
6,122,207
Members
449,074
Latest member
cancansova

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