Oberon70
Board Regular
- Joined
- Jan 21, 2022
- Messages
- 160
- Office Version
- 365
- Platform
- Windows
Hi,
I am trying to hide rows in the below code, but for some reason is it not working.
Case 59 is the line I am wanting to use to hide rows if a cell is not blank.
I am trying to hide rows in the below code, but for some reason is it not working.
Case 59 is the line I am wanting to use to hide rows if a cell is not blank.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim hr As Double
hr = ActiveCell.Row
Debug.Print hr
' If Sheets("Rapid Receipting").Range("AB57") <> "" Then Rows("1:" & hr).EntireRow.Hidden = True
If Intersect(Target, Columns("AA")) Is Nothing Then Exit Sub 'stop if you ddin't right click in the AA-column
'later instead of that msgbox, you do target.offset(......).COPY
Select Case Target.Row Mod 60 'depending on the rownumber (modulus 60 !!), choose a range
Case 2: Target.Offset(, 2).Resize(16, 2).Copy
Case 19 To 20: Target.Offset(, 2).Resize(1, 47).Copy
Case 21: Target.Offset(, 2).Resize(1, 31).Copy
Case 24, 37: Target.Offset(, 2).Resize(12, 3).Copy
Case 50: Target.Offset(, 2).Resize(8, 3).Copy
Case 59: If Range("AC59").Value <> "" Then Rows("1:" & Target.Offset(, 2).Row).EntireRow = Hidden
Case Else: Exit Sub
End Select
End Sub