MrExcel Publishing
Your One Stop for Excel Tips & Solutions

hiding rows using conditional formatting


Posted by rich on December 28, 2001 6:26 PM

Is there a way to hide an entire row based on the criteria in a given cell in that row using the conditional formatting command? If not, is there another way (outside of conditional formatting)?

thanks,


Posted by Jacob on December 28, 2001 6:38 PM

Hi

With formatting you cant do this.

With VB you can.

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)

If Target.Value = 1 Then
Rows(Target.Row).RowHeight = 0
Else
End If

End Sub

Change the =1 to whatever you want in order for the code to trigger.

Hope this helps

Jacob

Posted by rich on December 28, 2001 6:41 PM

Jacob: Thanks for the quick response. I'm not sure I understand your answer completely. How do I do what you suggest?

:: Hi

Posted by Jacob on December 28, 2001 8:37 PM

In Excel press Alt + F11 to open the vb
double click on the This Workbook Code
Paste the code there


Jacob : Thanks for the quick response. I'm not sure I understand your answer completely. How do I do what you suggest?

Posted by rich on December 29, 2001 6:05 AM

Jacob: can you please email a small spreadsheet to me that does what you suggest? I can't get it to work.


Posted by Phil D. Gonzalez on January 03, 2002 1:21 PM

Hi Jacob,

I'm trying to get more familiar with VBA coding, and have just a quick question.

Why would you use:

Rows(Target.Row).RowHeight = 0

instead of something like:

Target.EntireRow.Hidden = True

Again, I'm not questioning your code. I'm just trying to figure out if there's any specific technical reason why you would choose one over the other. Hi

Posted by Feste on January 03, 2002 6:44 PM

They do the same thing. No reason to choose one over the other

I'm trying to get more familiar with VBA coding, and have just a quick question. Why would you use: Rows(Target.Row).RowHeight = 0 instead of something like: Target.EntireRow.Hidden = True Again, I'm not questioning your code. I'm just trying to figure out if there's any specific technical reason why you would choose one over the other. : Hi