Connorwild
New Member
- Joined
- May 20, 2020
- Messages
- 5
- Office Version
- 2007
- Platform
- Windows
Hi all,
I have limited knowledge of VBA - mainly pieced together from various google searches until it works. From this, I've been able to create macro buttons to reset my data and hide/unhide rows based on single criteria, but my problem comes when trying to hide/unhide rows (12:27) based on numerical criteria pulled from two cells in a different row (6).
My current code:
Currently, if D6 is empty or less than 100,000, the range is hidden. More than or equal to 100,000, the range is shown. Ideally I'd like to include the value from C6 in the calculation, this will be empty or more than 0 - this is where I struggle and cannot decipher what I'm finding online.
If C6 is more than 1 AND D6 is more than 100,000 - show range. All other scenarios, including a partial combination (i.e. C6 not empty but D6 less than 100,000), the range would remain hidden.
Whilst I know the below isn't correct, it might demonstrate what I mean a bit clearer:
C6 or D6 "" or D6 < 100000: Range("12:27").EntireRow.Hidden = True
C6 >1 and D6 >= 100000: Range("12:27").EntireRow.Hidden = False
Thanks in advance!
Connor
I have limited knowledge of VBA - mainly pieced together from various google searches until it works. From this, I've been able to create macro buttons to reset my data and hide/unhide rows based on single criteria, but my problem comes when trying to hide/unhide rows (12:27) based on numerical criteria pulled from two cells in a different row (6).
My current code:
VBA Code:
Private Sub Worksheet_Change_B(ByVal Target As Range)
Select Case Range("D6").Value
Case "": Range("12:27").EntireRow.Hidden = True
Case Is < 100000: Range("12:27").EntireRow.Hidden = True
Case Is >= 100000: Range("12:14").EntireRow.Hidden = False
End Select
End Sub
Currently, if D6 is empty or less than 100,000, the range is hidden. More than or equal to 100,000, the range is shown. Ideally I'd like to include the value from C6 in the calculation, this will be empty or more than 0 - this is where I struggle and cannot decipher what I'm finding online.
If C6 is more than 1 AND D6 is more than 100,000 - show range. All other scenarios, including a partial combination (i.e. C6 not empty but D6 less than 100,000), the range would remain hidden.
Whilst I know the below isn't correct, it might demonstrate what I mean a bit clearer:
C6 or D6 "" or D6 < 100000: Range("12:27").EntireRow.Hidden = True
C6 >1 and D6 >= 100000: Range("12:27").EntireRow.Hidden = False
Thanks in advance!
Connor