Hi,
In another thread, which is unfortunately more than 365 days old, I found a code to automatically hide/unhide rows with a VBA code. When I implement this code in my sheet it works like a charm. See the code below:
Code
- Private Sub Worksheet_Change(ByVal Target As Range)
- '// Ignore if more than 1 cell changes
- If Target.Cells.Count <> 1 Then Exit Sub
- '// If Column E, rows 14 to 24 changed
- If Not Intersect(Target, Range("E14:E24")) Is Nothing Then
- '// If it's an even row ( = 1 for Odd rows)
- If Target.Row Mod 2 = 0 Then
- Target.Offset(2).EntireRow.Hidden = (Target.Value = vbNullString)
- End If
- End If
- End Sub
I have multiple sheets. Now, I have implemented the code above in a module so that I can call the module with the active sheet. When the range in the sheets change I can easily change it in the module instead of changing it in every sheets code.
I call the module with the code below:
It calls the module but the code in the module doesn't work. It only seems to work when directy in the sheets code.
How can I adjust it to work?
Kind regards.