I have a sheet where (starting at column E), each alternate column has a header.
eg
E F G H etc.....
31_02_Datannn (blank) 31_02_Field (blank)
I need code which (starting at column E) looks for the word "Field" within the column headers and if found, does nothing but skips to the next column with a header. If "Field" is not found, I need to delete both the column with the heading and the one to the right of it - then continue the same check until the last column is reached.
I have the following work in progress code (which currently does not work) - can anyone help please?
LastColumn = Range("IV1").End(xlToLeft).Column
ColumnNumber = 5 'The First column number with an object in the heading
ValIn = Cells(1, ColumnNumber)
Do While ColumnNumber <= LastColumn
If InStr(1, ValIn, "Field", vbTextCompare) = 0 Then
Range("ColumnNumber:ColumnNumber + 1").Delete
ColumnNumber = ColumnNumber + 2
MsgBox (ColumnNumber)
End If
Loop
eg
E F G H etc.....
31_02_Datannn (blank) 31_02_Field (blank)
I need code which (starting at column E) looks for the word "Field" within the column headers and if found, does nothing but skips to the next column with a header. If "Field" is not found, I need to delete both the column with the heading and the one to the right of it - then continue the same check until the last column is reached.
I have the following work in progress code (which currently does not work) - can anyone help please?
LastColumn = Range("IV1").End(xlToLeft).Column
ColumnNumber = 5 'The First column number with an object in the heading
ValIn = Cells(1, ColumnNumber)
Do While ColumnNumber <= LastColumn
If InStr(1, ValIn, "Field", vbTextCompare) = 0 Then
Range("ColumnNumber:ColumnNumber + 1").Delete
ColumnNumber = ColumnNumber + 2
MsgBox (ColumnNumber)
End If
Loop
Last edited: