StorminASU
New Member
- Joined
- Aug 9, 2011
- Messages
- 36
Hello everyone, I have a workbook that needs to hide columns if a cell value is less than 0 and, as something entirely separate, hide numerous rows if nothing is displayed in them. Both of these will be pulling their conditional cells from cells with formulas in them. For example, the macro which will decide to hide rows will be targeting cells that have formulas which are set to "" if they need to be hidden. Same thing with the column.
Currently I'm using this code, but it doesn't seem to be updating as the formula in W10 changes. Here is the formula in W10 now: "=IF(W18>0,"TRUE","FALSE")"
Here is the code to hide the column, which is working, but not as the formula changes:
In addition to not knowing how to get the column to hide/unhide more automatically based on the formula results, I have no clue how to hide/unhide the rows. For values in B69:B100, if the formula result is "", the row needs to be hidden. The formula in column B is as follows, with a blank row between each 5 year increment.
=IF(B68="","",IF(B68=0,0,IF(B68+1>100,"",B68+1)))
Thank you very much for any help you can offer!
Currently I'm using this code, but it doesn't seem to be updating as the formula in W10 changes. Here is the formula in W10 now: "=IF(W18>0,"TRUE","FALSE")"
Here is the code to hide the column, which is working, but not as the formula changes:
Code:
Private Sub Worksheet_Change(ByVal Target As Range) If Not Application.Intersect(Target, Me.Range("W10")) Is Nothing Then
If Target.Cells(1).Value = "TRUE" Then
Me.Columns("w").Hidden = False
Else
Me.Columns("w").Hidden = True
End If
End If
End Sub
In addition to not knowing how to get the column to hide/unhide more automatically based on the formula results, I have no clue how to hide/unhide the rows. For values in B69:B100, if the formula result is "", the row needs to be hidden. The formula in column B is as follows, with a blank row between each 5 year increment.
=IF(B68="","",IF(B68=0,0,IF(B68+1>100,"",B68+1)))
Thank you very much for any help you can offer!