I am trying to use find the last row of a merged cell with text and hide all rows beside that
For example:
A1:A5 is a merged cell with text "A", A6:A10 is a merged cell with text "B", etc
I want to write a code that would find the last row of the merged cell with text "B", and would hide any rows above or below the merged cell.
At the moment I am defining the rows to hide manually, but these change frequently so my method is not very efficient.
Any suggestions on how to find the last row instead?
Sub FindLastRow() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Test") 'Hide all rows above B ws.Rows("1:5").EntireRow.Hidden = True 'Hide all rows below B ws.Rows("11:80").EntireRow.Hidden = True End Sub
Application.Matchshould be helpful.Range.Find, which accomplishes the same thing.