Hi,
I am new to VBA and have gone through all the codes for my problem but none of it is working.
This is the code I want to run on Multiple sheets-
----------------------------------------------
Sub Delete_Columns()
Target1 = "Product Category"
Target2 = "Total"
Target3 = "TAS"
Range("A1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = Target1 Or ActiveCell.Value = Target2 Then
ActiveCell.EntireColumn.Delete
Else
ActiveCell.Offset(0, 1).Activate
End If
If ActiveCell.Value = Target3 Then
ActiveCell = "TelephoneNumber"
Else
ActiveCell.Offset(0, 1).Activate
End If
loop
end sub
------------------------------------
This is the code with which I am trying to make it work on multiple sheets
---------------------------------------------
Sub Delete_Columns()
Dim intSheetIndex As Integer
Target1 = "Product Category"
Target2 = "Total"
Target3 = "TAS"
'I can add as many target columns I want
For ws = (Sheets("AC").Index + 1) To (Sheets("Unassigned").Index - 1)
Sheets(ws).Activate
Range("A1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = Target1 Or ActiveCell.Value = Target2 Then
ActiveCell.EntireColumn.Delete
Else
ActiveCell.Offset(0, 1).Activate
End If
If ActiveCell.Value = Target3 Then
ActiveCell = "TelephoneNumber"
Else
ActiveCell.Offset(0, 1).Activate
End If
Next ws
End Sub
-----------------------------------
This gives a compile error "Next without For". Please help.
Thanks
~S
Bookmarks