![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Sunny, spring-like Hull
Posts: 3,339
|
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 ] |
|
|
|
|
|
#3 |
|
New Member
Join Date: Mar 2002
Location: England
Posts: 46
|
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 ] |
|
|
|
|
|
#4 |
|
Board Regular
Join Date: Feb 2002
Location: Huntington Beach, CA USA
Posts: 327
|
Thanks, guys i appreciate it.
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|