I've tried many things already but none of them are working.
I'm trying to loop through the 2nd cell (1st after header) of each column, check what they are and delete them if they fulfill certain conditions. The idea is to loop up to the end of the document (last column) and only there stop and display a message box.
Thing is, every time it encounters a cell without one of the specified values (the ones to delete) it breaks the loop and displays the Message Box
How could I fix this?
Sub DeleteColumns()
Set Data = Range("A1:AT1")
For Each cell In Data
If cell.Value = "Product Id" Or cell.Value = "Status" Or cell.Value = "Constdate" Or cell.Value = "Warranty Months" _
Or cell.Value = "Partner" Or cell.Value = "Warranty Id" Or cell.Value = "Warranty Type" Or cell.Value = "Date Check" _
Or cell.Value = "Order Number" Or cell.Value = "Delivery Number" Or cell.Value = "Return Date" Or cell.Value = "Pop Date" _
Or cell.Value = "User text" Or cell.Value = "Error Message" Or cell.Value = "QuickSheetDesc" Or cell.Value = "PTC" _
Or cell.Value = "Prod_Enum" Or cell.Value = "Wty_Product" Or cell.Value = "BP1 Discount" Then
cell.EntireColumn.Delete
Else
End If
Next cell
MsgBox "Columnas eliminadas"
End Sub
I tried with GoTo functions, with ElseIf Not IsEmpty(cell) and a few other things that didn't work, so I guess it's bad syntax/logic from the get go.