Sub Macro3()
Dim col1, col2, colTemp
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
col1 = Rows(1).Find(What:="Check Amount", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Column
col2 = Rows(1).Find(What:="Account Number", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Column
If col1 < col2 Then
colTemp = col1
col1 = col2
col2 = colTemp
End If
Range(Cells(1, col1 + 1), Cells(1, Columns.Count)).EntireColumn.Delete
If col1 > col2 + 1 Then Range(Cells(1, col2 + 1), Cells(1, col1 - 1)).EntireColumn.Delete
Range(Cells(1, 1), Cells(1, col2 - 1)).EntireColumn.Delete
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
|