I am trying to create a table that would hide a row based on the value from another row which is what I think makes it complicated.
I have a table that populates from another table where I input data (both on the same sheet). I have three rows where I input data 28-30. I want the code to look at column B in 28-30 and hide rows 10-12 if the values in 28-30 are zero. Row 10 populates from 28, 11 from 29 and 12 from 30. Therefore if 28 and 29 had a value of 1 in it and 30 had zero, only 12 would disappear.
I can get one row to hide with the code below, but not the rest because it keeps looking at 10. I'm guessing I need some sort of "next" statement.
Ideally, I would like to make this happen automatically (I hear "Events" will do that) and unhide the rows if there is a value other than zero. Also, I would like this to apply to multiple sheets of the same layout in the same workbook.
Am I asking too much of Visual Basic?
Sub HideRow()
'
' HideRow Macro
'
BeginRow = 28
EndRow = 30
ChkCol = 2
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 0 Then
Rows("10").EntireRow.Hidden = True
Else
Rows("10").EntireRow.Hidden = False
End If
Next RowCnt
End Sub
I have a table that populates from another table where I input data (both on the same sheet). I have three rows where I input data 28-30. I want the code to look at column B in 28-30 and hide rows 10-12 if the values in 28-30 are zero. Row 10 populates from 28, 11 from 29 and 12 from 30. Therefore if 28 and 29 had a value of 1 in it and 30 had zero, only 12 would disappear.
I can get one row to hide with the code below, but not the rest because it keeps looking at 10. I'm guessing I need some sort of "next" statement.
Ideally, I would like to make this happen automatically (I hear "Events" will do that) and unhide the rows if there is a value other than zero. Also, I would like this to apply to multiple sheets of the same layout in the same workbook.
Am I asking too much of Visual Basic?
Sub HideRow()
'
' HideRow Macro
'
BeginRow = 28
EndRow = 30
ChkCol = 2
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value = 0 Then
Rows("10").EntireRow.Hidden = True
Else
Rows("10").EntireRow.Hidden = False
End If
Next RowCnt
End Sub