my progress w/ Hide - UnHide Rows w/ Vba

G

Guest

Guest
Hi,

In my haste i guess i didn't explain well
enough what im trying to do. I'll try again:

Say i have a range from A6:A1000, if in any
row in column A witin A6:A1000 contains a "0"
then that row is hidden. I can get it to work
with this "lame" code but it's ridiculous
as you can see....

Private Sub CommandButton1_Click()
If [A6,A7,A8,A9].Value > 0 Then
Range("A6,A7,A8,A9").EntireRow.Hidden = False
End If

If [A6].Value = 0 Then
Range("A6"). EntireRow.Hidden = True
End If

If [A7].Value = 0 Then
Range("A7"). EntireRow.Hidden = True
End If
End Sub

'It works "but it's obviously not the way to
go to check 1,000 rows"

Any help would be appreciated

James
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
The following should work OK: -

Private Sub CommandButton1_Click()

Dim myRange As Range
Dim c As Range

Set myRange = Range("A6:A1000")
Application.ScreenUpdating = False

For Each c In myRange
If c.Value = 0 Then
c.EntireRow.Hidden = True
Else:
c.EntireRow.Hidden = False
End If
Next c

Application.ScreenUpdating = True

End Sub

Ooops, forgot my screenupdating stuff :).
This message was edited by Mudface on 2002-03-09 14:01
 
Upvote 0
Try this

Public Sub HideRows()
Dim c As Object
For Each c In Range("$A$6:$A$1000")
If c = "0" Then
c.EntireRow.Hidden = True
End If
Next c
End Sub
This message was edited by waggy30 on 2002-03-09 14:08
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,746
Members
448,989
Latest member
mariah3

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