Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to hide multiple rows
Hi,
I am writing a macro at the moment that hides a row given a certain criteria is met. However, at the moment I have had to do this on a row by row basis: e.g. If A8 = Cat Then Rows("8:8").Select Selection.EntireRow.Hidden = True End If If A9 = Cat Then Rows("9:9").Select Selection.EntireRow.Hidden = True End If etc.... Is there a way to do this to a range of cells rather than on a cell by cell basis? Thanks heaps. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to hide multiple rows
Hi
You will have to loop cell by cell for this, but it's easy and fast: Sub test() Dim R As Range, Cel As Range Set R = Range("A1:M300") For Each Cel In R If Cel.Value = "Cat" Then _ Cel.EntireRow.Hidden = True Next End Sub HTH. Best wishes Harald "Minh" skrev i melding ... Hi, I am writing a macro at the moment that hides a row given a certain criteria is met. However, at the moment I have had to do this on a row by row basis: e.g. If A8 = Cat Then Rows("8:8").Select Selection.EntireRow.Hidden = True End If If A9 = Cat Then Rows("9:9").Select Selection.EntireRow.Hidden = True End If etc.... Is there a way to do this to a range of cells rather than on a cell by cell basis? Thanks heaps. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro to hide multiple rows
alternatively, you might want to look into using filtering for this ... if
you use the macro recorder and data / autofilter .. and use the custom option to display only those rows not equal to cat - it might give you what you want. Cheers JulieD "Harald Staff" wrote in message ... Hi You will have to loop cell by cell for this, but it's easy and fast: Sub test() Dim R As Range, Cel As Range Set R = Range("A1:M300") For Each Cel In R If Cel.Value = "Cat" Then _ Cel.EntireRow.Hidden = True Next End Sub HTH. Best wishes Harald "Minh" skrev i melding ... Hi, I am writing a macro at the moment that hides a row given a certain criteria is met. However, at the moment I have had to do this on a row by row basis: e.g. If A8 = Cat Then Rows("8:8").Select Selection.EntireRow.Hidden = True End If If A9 = Cat Then Rows("9:9").Select Selection.EntireRow.Hidden = True End If etc.... Is there a way to do this to a range of cells rather than on a cell by cell basis? Thanks heaps. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How do I hide multiple rows under one row IN EXCEL? | Excel Worksheet Functions | |||
Macro code to hide rows and not calculate hidden rows | Excel Discussion (Misc queries) | |||
hide rows with macro | Excel Discussion (Misc queries) | |||
macro to hide rows | Excel Discussion (Misc queries) | |||
Macro to hide rows | Excel Programming |