Hi,
In which cell is the original choice of Yes No ... because it is this cell that the event macro has to monitor in order to hide or not your row 7 ...
HTH
Carim
![]()
Hi,
In which cell is the original choice of Yes No ... because it is this cell that the event macro has to monitor in order to hide or not your row 7 ...
HTH
Carim
![]()
Hi again,
Adjust the following to your situation ...
HTH![]()
Private Sub Worksheet_Change(ByVal Target As Range) Set Target = Range("A1") '<-------------------adjust to your needs If Target.Value = "No" Then Target.Offset(6, 0).EntireRow.Hidden = True '<--adjust 6 to your needs ElseIf Target.Value = "Yes" Then Target.Offset(6, 0).EntireRow.Hidden = False '<--adjust 6 to your needs End If End Sub
Carim
![]()
Thanks for that - it's great!![]()
How about if I wish to hide more than one consecutive row? Would that just require me to change the Target.Offset e.g., if I wanted to hid three rows, would I put (6, 3), (6,9) or something else?
Cheers,
Baldy
HTH![]()
Private Sub Worksheet_Change(ByVal Target As Range) Set Target = Range("A1") If Target.Value = "No" Then Target.Offset(3, 0).EntireRow.Hidden = True Target.Offset(6, 0).EntireRow.Hidden = True Target.Offset(9, 0).EntireRow.Hidden = True ElseIf Target.Value = "Yes" Then Target.Offset(3, 0).EntireRow.Hidden = False Target.Offset(6, 0).EntireRow.Hidden = False Target.Offset(9, 0).EntireRow.Hidden = False End If End Sub
Carim
![]()
Where 3,6 & 9 are just the relative distance from the target row, yes?
And - sorry to be a nuisance - if I need to have more than one of these things on the same worksheet, how do I do that? I tried pasting the thing and renaming the subroutine to Worksheet_Change2 and also changing the variable name target to target2, but no luck...![]()
Yes ... the offset() function, to use your terminology, works with "relative distance" ....
You can have many worksheets events with different events ... but for a given event you can only have one of each ...
Solution : code all your requirements within that particular one ...
HTH
Carim
![]()
Lovely - thanks for all your help!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks