ronald54457874
New Member
- Joined
- Sep 26, 2021
- Messages
- 17
- Office Version
- 2013
Hello, I need help to hide the column "O", but it can only be hidden IF it has the value "XYZ" in one of the cells of the column "K" AND if the cells of the column "M" has nothing or i.e. be different from 0.
I tried this but it didn't work;
My Logic
Apparently it's not difficult but I don't have the skills yet to make this code. Thanks to anyone who can help.
I tried this but it didn't work;
VBA Code:
Dim C As Range
Dim ABC As Range
Dim DEF As Range
Set C = Range("O:O")
Set DEF = Range("M:M").Select
For Each ABC In Range("L:L").Cells
If ABC.Value = "XYZ" And DEF.Value <> 0 Then
C.EntireColumn.Hidden = False
ElseIf ABC.Value <> "XYZ" Then
C.EntireColumn.Hidden = True
End If
Next
My Logic
VBA Code:
If Columns("K").Value = "XYZ" And Columns("M").Value <> 0 Then
Columns("o:o").Select
Selection.EntireColumn.Hidden = False
End If
Apparently it's not difficult but I don't have the skills yet to make this code. Thanks to anyone who can help.