Expand and collapse rows

R

ravilal123

I am using the following code as master code to hide unhide rows in a spreadsheet. This code conststs of several ranges. I am also using similar code to hide unhide indiviual range.

This code works fine if all the ranges are either hidden or unhidden. However, if one range is unhidden, and remaining hidden then the codes firsts hides open rows then unhides the remaining rows and viseversa.

I want all the rows to open or close when I run the code regardless of its position (open/close) at the time of running the code.

Note - I have created a button on the sheet to activate this code.

Sub Hide_Unhide6()
For Each cell In Range("A7:A15,A17:A60,A62:A92,A94:A111,A113:A113")
If cell.EntireRow.Hidden = False Then
cell.EntireRow.Hidden = True
Else
cell.EntireRow.Hidden = False
End If
Next
End Sub
 
C

Claus Busch

Hi,

Am Fri, 13 Jun 2014 13:37:30 -0700 (PDT) schrieb (e-mail address removed):
Sub Hide_Unhide6()
For Each cell In Range("A7:A15,A17:A60,A62:A92,A94:A111,A113:A113")
If cell.EntireRow.Hidden = False Then
cell.EntireRow.Hidden = True
Else
cell.EntireRow.Hidden = False
End If
Next
End Sub

please have a look:
https://onedrive.live.com/?cid=9378...#cid=9378AAB6121822A3&id=9378AAB6121822A3!326
for "HideRows"
Rightclick and download the file because macros are disabled in
OneDrive.


Regards
Claus B.
 
R

ravilal123

I am using the following code as master code to hide unhide rows in a spreadsheet. This code conststs of several ranges. I am also using similar code to hide unhide indiviual range. This code works fine if all the ranges are either hidden or unhidden. However, if one range is unhidden, and remaining hidden then the codes firsts hides open rows then unhides the remaining rows and viseversa. I want all the rows to open or close when I run the code regardless of its position (open/close) at the time of running the code. Note - I have created a button on the sheet to activate this code. Sub Hide_Unhide6() For Each cell In Range("A7:A15,A17:A60,A62:A92,A94:A111,A113:A113") If cell.EntireRow.Hidden = False Then cell.EntireRow.Hidden = True Else cell.EntireRow.Hidden = False End If Next End Sub

Thank you Claus .. I will try that.
 
R

Ravi Lal

Hi, Am Fri, 13 Jun 2014 13:37:30 -0700 (PDT) schrieb (e-mail address removed): > Sub Hide_Unhide6() > For Each cell In Range("A7:A15,A17:A60,A62:A92,A94:A111,A113:A113") > If cell.EntireRow.Hidden = False Then > cell.EntireRow.Hidden = True > Else > cell.EntireRow.Hidden = False > End If > Next > End Sub please have a look: https://onedrive.live.com/?cid=9378...#cid=9378AAB6121822A3&id=9378AAB6121822A3!326 for "HideRows" Rightclick and download the file because macros aredisabled in OneDrive. Regards Claus B. -- Vista Ultimate / Windows7 Office2007 Ultimate / 2010 Professional

Thanks again Claus for providing the worksheet with a revised code. I aplogize, but I am not at all good in VBA, and having trouble running the code.
I created a CommandButton1 but it's not working :-(
I tried running the script from the editor, and it's giving me 'Run-time error '32809': Application-defined or object error'.

PLease advise.

Ravi Lal
 
C

Claus Busch

Hi Ravi,

Am Tue, 17 Jun 2014 13:05:08 -0700 (PDT) schrieb Ravi Lal:
Thanks again Claus for providing the worksheet with a revised code. I aplogize, but I am not at all good in VBA, and having trouble running the code.
I created a CommandButton1 but it's not working :-(
I tried running the script from the editor, and it's giving me 'Run-time error '32809': Application-defined or object error'.

can't you paste your data into my file?
If not send your file to my email address and create a comment in your
file where you describe your expected result


Regards
Claus B.
 
R

ravilal123

Hi Ravi, Am Tue, 17 Jun 2014 13:05:08 -0700 (PDT) schrieb Ravi Lal: > Thanks again Claus for providing the worksheet with a revised code. I aplogize, but I am not at all good in VBA, and having trouble running the code. > Icreated a CommandButton1 but it's not working :-( > I tried running the script from the editor, and it's giving me 'Run-time error '32809': Application-defined or object error'. can't you paste your data into my file? If notsend your file to my email address and create a comment in your file whereyou describe your expected result Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional

Sure I can .. which email please :)
 
C

Claus Busch

Hi,

Am Tue, 17 Jun 2014 13:26:21 -0700 (PDT) schrieb (e-mail address removed):
Sure I can .. which email please :)

claus_busch[at]t-online.de


Regards
Claus B.
 
R

ravilal123

Hi, Am Tue, 17 Jun 2014 13:26:21 -0700 (PDT) schrieb (e-mail address removed): > Sure I can .. which email please :) claus_busch[at]t-online.de Regards Claus B. -- Vista Ultimate / Windows7 Office 2007 Ultimate / 2010 Professional

Please send a blank email to (e-mail address removed)
My emai is not recognizing your address: claus_busch[at]t-online.de


Thanks - Ravi
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top