I'm trying to hide/unhide rows in "Output" sheet conditional on cell values in "Input" sheet. That in itself isn't the most difficult part, but I'm having troubles with the loop as I need to hide 300 rows based on 300 cell values individually.
So for example, I would like to hide row 12 in "Output" sheet if cell B6 in "Input" sheet contains a "No". Then I would like to hide row 13 in "Output" sheet if cell B7 in "Input" sheet contains a "No"... all the way until row 306 and B300.
I've written the following code so far but it doesn't seem to be working. Any help is very much appreciated!
Sub HideRow()
Dim i As Integer, j As Integer
For i = Sheets("Input").Range("B6") To Sheets("Input").Range("B300")
For j = Sheets("Output").Rows("12") To Sheets("Output").Rows("306")
If Sheets("Input").Range("i").Value = "No" Then
Sheets("Output").Rows("j").EntireRow.Hidden = True
Else
Sheets("Output").Rows("j").EntireRow.Hidden = False
Next j
Next i
End Sub
For i = Sheets("Input").Range("B6") To Sheets("Input").Range("B300")
should be replaced withFor i = 6 to 300
. The same for the next iteration. Then, your code will hide all "Output" sheet rows if the condition is true... Can you better explain in which conditions the rows in "Output" sheet must be hidden? Rangei
das not mean anything for VBA. Please explain (in words) what you want to accomplish. Do you need to hide the same row of the other sheet, if the condition in the first one is true? – FaneDuru