jewkes6000
Board Regular
- Joined
- Mar 25, 2020
- Messages
- 60
- Office Version
- 365
- Platform
- Windows
I am trying to cycle through several columns and delete the columns which have the word "HIDE" in a specific cell. I'm able to cycle through the cells; however, whenever a cell contains the word "Hide", it skips it as if the statement is NOT true. The cell does contain a formula which generates the cell value, but I though the code should still recognize the value. Why is the if statement "skipping" to the next column when the cell actually says "Hide"? I've also included a google drive link below to see the actual file.
Any help is much appreciated.
Any help is much appreciated.
VBA Code:
Sub Delete_Columns()
'This will cycle through columns and delete those which are marked as "hide"
For i = 22 To 237
Columns(i).Select
If ActiveCell = "Hide" Then
Columns(i).Delete
Else
ActiveCell.Offset(1, 0).Range("A1").Select
End If
If ActiveCell = "Hide" Then
Columns(i).Delete
Else
End If
Next i
End Sub
Delete Columns Bases on Text (Mr Excel).xlsm
drive.google.com