I have some very basic VBA code here
sub HideRows_Based_On_Values
For Each cell in Range (C12:AG37)
if cell.value = "SD" or "SA" or "SN" then cell.entirerow.hidden = false
else cell.entirerow.hidden = true
next cell
End Sub
The range is correct, the inputs in the cells are correct.
For some reason, excel is hiding some (not all) of the rows that have at least one of these values present in them. I can't figure out what I'm doing wrong.
I expected for the code to filter out any rows that don't have one of SD, SA, or SN present - but it's only working on some of the rows and not all.
CodePudding user response:
sub HideRows_Based_On_Values
For Each cell in Range (C12:AG37)
if cell.value = "SD" OR cell.value = "SA" OR cell.value = "SN" then
cell.entirerow.hidden = false
else
cell.entirerow.hidden = true
end if
next cell
End Sub
CodePudding user response:
Not:
A = 1 OR 2 OR 3
But:
(A = 1) OR (A = 2) OR (A = 3)
This is true in every computer program, computer programming language, ...