Forum Discussion
BriceChapman
Mar 06, 2024Copper Contributor
Search a column for 2 rows with keywords and hide what's in between them
Hi everyone, I am trying to hide a section of rows from my excel sheet, the issue being the location of this section is dynamic. Below is an example of my sheet Agented aaa Non - Age...
OliverScheurich
Mar 06, 2024Gold Contributor
Sub hide()
Dim h, i, j, k As Long
h = Range("A" & Rows.Count).End(xlUp).Row
i = Application.WorksheetFunction.Match("Non - Agented", Range("A:A"), 0)
j = Application.WorksheetFunction.Match("Amendments", Range("A:A"), 0)
For k = 1 To h
If k >= i And k < j Then
Rows(k).Hidden = True
Else
End If
Next k
End Sub
In the attached file you can run these lines of code to hide the rows between the keywords if the data is in column A. There is a macro to unhide the range as well.