Johnson Jason
Johnson Jason

Reputation: 721

Using VBA in Excel, How do I clear everything past a specific column?

I have this for clearing everything past a specific row but I would like it to work with columns instead of rows. X in this case should be 6

  With Sheets("Sheet1")
      .Rows( X & ":" & .Rows.Count).ClearContents
  End With

Upvotes: 0

Views: 36

Answers (1)

OpiesDad
OpiesDad

Reputation: 3435

 With Sheets("Sheet1")
      .Range(.Cells(1,X).Address & ":" & .Cells(1,.Columns.Count).Address).Columns.ClearContents
 End With

where X is the column number or letter you wish to start with.

Upvotes: 2

Related Questions