Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub hideRowsBetweenListObjects(sheetName As String)
- Dim tblRowPosition1 As Integer
- Dim tblNrOfRows1 As Integer
- Dim tblRowPosition2 As Integer
- Dim tblNrOfRows2 As Integer
- 'Initialize
- Application.ScreenUpdating = False
- With Worksheets(sheetName).ListObjects(1)
- tblRowPosition1 = .Range.Row
- tblNrOfRows1 = .Range.Rows.Count
- End With
- With Worksheets(sheetName).ListObjects(2)
- tblRowPosition2 = .Range.Row
- tblNrOfRows2 = .Range.Rows.Count
- End With
- With Worksheets(sheetName)
- If tblRowPosition1 < tblRowPosition2 Then
- .Range(.Cells(tblRowPosition1 + tblNrOfRows1, 1), .Cells(tblRowPosition2 - 4, 1)).EntireRow.Hidden = True
- ElseIf tblRowPosition2 < tblRowPosition1 Then
- .Range(.Cells(tblRowPosition2 + tblNrOfRows2, 1), .Cells(tblRowPosition1 - 4, 1)).EntireRow.Hidden = True
- End If
- End With
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement