Delete columns
Try This
Sub DeleteColumns()
LastColumn = Cells(1, Columns.Count).End(xlToLeft).Column
Set HeaderRange = Range(Cells(1, 2), Cells(1, LastColumn))
Set c = HeaderRange.Find("Total", LookIn:=xlValues)
If Not c Is Nothing Then
Set DeleteRange = Range(Cells(1, 2), _
Cells(1, c.Column - 1))
DeleteRange.EntireColumn.Delete
End If
End Sub
"Mike D." wrote:
Hi. I'm looking for a way to delete a series of columns, starting in column
"B". I want to search for the word, "Total" in row 1. I want to delete all
columns up to the column with the word "Total in it. For instance, If J1
contains "Total", I would want to delete columns B through I.
Thanks,
Mike.
|