Share via

Hide rows when specific cell is blank

Anonymous
2023-04-01T16:52:45+00:00

Hi all, could some one help me for a macro to hide ranges of rows when specific cell is blank.

If cell K9 is blank, then the macro should hide the rows starting from row number 9 to 15 and then again if K18 is blank, then hide rows from 18 to 27.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2023-04-01T17:34:33+00:00

Hi Nagul1,

I'm Femi and I'd be happy to help you with your question.

Kindly try the macro below and let me know if it works:

Sub HideRowsIfCellsBlank() 'Hide rows 9 to 15 if cell K9 is blank If IsEmpty(Range("K9")) Then Rows("9:15"). EntireRow.Hidden = True End If

'Hide rows 18 to 27 if cell K18 is blank If IsEmpty(Range("K18")) Then Rows("18:27"). EntireRow.Hidden = True End If End Sub

NOTE: This macro was made based on the conditions stated above. You can modify based on your preferences.

Best Regards,

Femi

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2023-04-01T18:24:07+00:00

    Hi Femi,

    The code is working great, thank you so much for the help!

    Was this answer helpful?

    0 comments No comments