ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA to hide rows? (https://www.excelbanter.com/excel-programming/381850-vba-hide-rows.html)

S Davis

VBA to hide rows?
 
Hello,

If possible, I would like a simple button to hide & show a set number
of rows (rows 5 - 35). Can this be done?

Thanks
-SD


Ron de Bruin

VBA to hide rows?
 
Hi S Davis

Rows(5 & ":" & 35).Hidden = True



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"S Davis" wrote in message oups.com...
Hello,

If possible, I would like a simple button to hide & show a set number
of rows (rows 5 - 35). Can this be done?

Thanks
-SD


S Davis

VBA to hide rows?
 

Thanks, thats great :) Works perfect.

Is there anything more elegant than the following for what I would like
to do? Id like to avoid the 'stepladder' visual that occurs when trying
to hide various rows.

ShowRows() essentially shows everything and then hides the ones I dont
want seen. Id prefer to do something like

Rows(8 & 10 & 12......).Hidden = False

but this is not accepted.

Ex (my code)
Sub HideRows()
Rows(5 & ":" & 42).Hidden = True
End Sub
Sub ShowRows()
Rows(1 & ":" & 42).Hidden = False
Rows(8).Hidden = True
Rows(10).Hidden = True
Rows(12).Hidden = True
Rows(14).Hidden = True
Rows(16).Hidden = True
Rows(18).Hidden = True
Rows(20).Hidden = True
Rows(22).Hidden = True
Rows(27).Hidden = True
Rows(29).Hidden = True
Rows(35).Hidden = True
Rows(37).Hidden = True
Rows(39).Hidden = True
Rows(41).Hidden = True
Rows(42).Hidden = True
End Sub

Thanks
-SD
On Jan 24, 12:32 pm, "Ron de Bruin" wrote:
Hi S Davis

Rows(5 & ":" & 35).Hidden = True

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"S Davis" wrote in ooglegroups.com...
Hello,


If possible, I would like a simple button to hide & show a set number
of rows (rows 5 - 35). Can this be done?


Thanks
-SD- Hide quoted text -- Show quoted text -



Ron de Bruin

VBA to hide rows?
 
You can use this

Range("A8,A10,a12").EntireRow.Hidden = True


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"S Davis" wrote in message ups.com...

Thanks, thats great :) Works perfect.

Is there anything more elegant than the following for what I would like
to do? Id like to avoid the 'stepladder' visual that occurs when trying
to hide various rows.

ShowRows() essentially shows everything and then hides the ones I dont
want seen. Id prefer to do something like

Rows(8 & 10 & 12......).Hidden = False

but this is not accepted.

Ex (my code)
Sub HideRows()
Rows(5 & ":" & 42).Hidden = True
End Sub
Sub ShowRows()
Rows(1 & ":" & 42).Hidden = False
Rows(8).Hidden = True
Rows(10).Hidden = True
Rows(12).Hidden = True
Rows(14).Hidden = True
Rows(16).Hidden = True
Rows(18).Hidden = True
Rows(20).Hidden = True
Rows(22).Hidden = True
Rows(27).Hidden = True
Rows(29).Hidden = True
Rows(35).Hidden = True
Rows(37).Hidden = True
Rows(39).Hidden = True
Rows(41).Hidden = True
Rows(42).Hidden = True
End Sub

Thanks
-SD
On Jan 24, 12:32 pm, "Ron de Bruin" wrote:
Hi S Davis

Rows(5 & ":" & 35).Hidden = True

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"S Davis" wrote in ooglegroups.com...
Hello,


If possible, I would like a simple button to hide & show a set number
of rows (rows 5 - 35). Can this be done?


Thanks
-SD- Hide quoted text -- Show quoted text -



S Davis

VBA to hide rows?
 
Fantastic Ron, thanks again!

On Jan 24, 1:39 pm, "Ron de Bruin" wrote:
You can use this

Range("A8,A10,a12").EntireRow.Hidden = True

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"S Davis" wrote in oglegroups.com...

Thanks, thats great :) Works perfect.


Is there anything more elegant than the following for what I would like
to do? Id like to avoid the 'stepladder' visual that occurs when trying
to hide various rows.


ShowRows() essentially shows everything and then hides the ones I dont
want seen. Id prefer to do something like


Rows(8 & 10 & 12......).Hidden = False


but this is not accepted.


Ex (my code)
Sub HideRows()
Rows(5 & ":" & 42).Hidden = True
End Sub
Sub ShowRows()
Rows(1 & ":" & 42).Hidden = False
Rows(8).Hidden = True
Rows(10).Hidden = True
Rows(12).Hidden = True
Rows(14).Hidden = True
Rows(16).Hidden = True
Rows(18).Hidden = True
Rows(20).Hidden = True
Rows(22).Hidden = True
Rows(27).Hidden = True
Rows(29).Hidden = True
Rows(35).Hidden = True
Rows(37).Hidden = True
Rows(39).Hidden = True
Rows(41).Hidden = True
Rows(42).Hidden = True
End Sub


Thanks
-SD
On Jan 24, 12:32 pm, "Ron de Bruin" wrote:
Hi S Davis


Rows(5 & ":" & 35).Hidden = True


--


Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm


"S Davis" wrote in ooglegroups.com...
Hello,


If possible, I would like a simple button to hide & show a set number
of rows (rows 5 - 35). Can this be done?


Thanks
-SD- Hide quoted text -- Show quoted text -- Hide quoted text -- Show quoted text -




All times are GMT +1. The time now is 01:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com