Hide and Unhide Rows

L

Legacy 287389

Guest
hi there,

I am battling to get rows to hide when vale in column A is zero,and to unhde when value is greater than zero. Any help will be greatly appreciated. Thank you...

I wanted to attach a spreadsheet, but cannot see the icon to use for this?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Hi Juriemagic,

This code should do what you are asking for...

Code:
Sub HideRw()

Dim LastRw As Long
Dim i As Long

LastRw = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

For i = 1 To LastRw

    If Sheets("Sheet1").Cells(i, "A").Value < 1 Then
        Rows(i).Hidden = True
    ElseIf Sheets("Sheet1").Cells(i, "A").Value >= 1 Then
        Rows(i).Hidden = False
    End If

Next

End Sub

Hope this helps,
Cheers,
Alan.
 
Upvote 0
Welcome to the Board!

How are the cell values changing (via formula or manually)?

For posting a screen shot you can follow the HTML Maker link in my sig.
 
Upvote 0
Hi Juriemagic,

This code should do what you are asking for...

Code:
Sub HideRw()

Dim LastRw As Long
Dim i As Long

LastRw = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row

For i = 1 To LastRw

    If Sheets("Sheet1").Cells(i, "A").Value < 1 Then
        Rows(i).Hidden = True
    ElseIf Sheets("Sheet1").Cells(i, "A").Value >= 1 Then
        Rows(i).Hidden = False
    End If

Next

End Sub

Hope this helps,
Cheers,
Alan.

Hi Alan,

Thank you for prompt reply. The code however does not execute. What I have is the following:

2 Sheets. Graph on Sheet 2. This graph displays info from sheet 1. It a multi legend line graph. Info on sheet 1 comes from a database sheet. Data
on sheet 1 changes by aid of criteria dropdowns on sheet 2. So:, I select criteria on sheet 2 with dropdown, sheet 1 looks for the criteria in Database sheet, and populates. Graph on Sheet 2 displays data. The problem is that rows with zero data should hide on sheet 1, so that only legends with data appears on chart. Hope this will help. Thanx for your time spent on this...
 
Upvote 0
Hi Smitty,

Cell values change from dropdown selection, and then via formulae...
 
Upvote 0

Forum statistics

Threads
1,216,014
Messages
6,128,282
Members
449,436
Latest member
blaineSpartan

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