Hide rows with VB

pioneerbank

New Member
Joined
Sep 14, 2011
Messages
2
I found this in your archive:

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
It's similar to what I want to do but I haven't been able to modify it sufficiently to work for me. I'm working on a financial statement and want to hide rows that contain all zeros, e.g. if SUM(b#:L#) = 0.

What do you suggest?
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
You could try:

Code:
[COLOR=black]Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) [/COLOR]
[COLOR=black]   If Application.Sum("B" & Target.Row & ":L" & Target.Row) = 0 Then[/COLOR]
[COLOR=black]        Rows(Target.Row).RowHeight = 0[/COLOR]
[COLOR=black]   End If [/COLOR]
[COLOR=red][COLOR=black]End Sub[/COLOR] [/COLOR]
 
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,486
Members
452,917
Latest member
MrsMSalt

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top