Home > Net >  How to correctly use a Range() in a Macro
How to correctly use a Range() in a Macro

Time:08-25

I have a very simple request that I can not figure out. I want to clear the contents out of cells A2:C.

I have column names in A1, B1, and C1 that I don't want cleared.

My Macro is:

Sub Clear_Contents()
Range("A2:C").ClearContents
End Sub

And I get an error. I can change the range to be "A2:C100" or any other hard coded number but I do not want that. I just want to clear from A2:A, B2:B, and C2:C.

Thanks in advance.

CodePudding user response:

Here's another way

Range("A2").Resize(Rows.Count-1,3).ClearContents
  • Related