ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If then, hidden rows (https://www.excelbanter.com/excel-programming/416134-if-then-hidden-rows.html)

pgarcia

If then, hidden rows
 
Hello all,
If rows a4-a10 are hidden, then un-hide, but if they are un-hidden, then hide.
Looking for a VB.

Thanks.

Rick Rothstein \(MVP - VB\)[_2661_]

If then, hidden rows
 
This should work (just set the worksheet reference according to your
needs)...

Dim R As Range
For Each R In Worksheets("Sheet1").Rows("4:10")
R.Hidden = Not R.Hidden
Next

Rick


"pgarcia" wrote in message
...
Hello all,
If rows a4-a10 are hidden, then un-hide, but if they are un-hidden, then
hide.
Looking for a VB.

Thanks.



Bob Phillips[_3_]

If then, hidden rows
 

With Rows("4:10")

.Hidden = Not .Hidden
End With

--
__________________________________
HTH

Bob

"pgarcia" wrote in message
...
Hello all,
If rows a4-a10 are hidden, then un-hide, but if they are un-hidden, then
hide.
Looking for a VB.

Thanks.




pgarcia

If then, hidden rows
 
GOD, I have to take a class one of these days.
Thanks you very much. It's got a cool "wow" factor when I have the VB code
in a com button.


"Rick Rothstein (MVP - VB)" wrote:

This should work (just set the worksheet reference according to your
needs)...

Dim R As Range
For Each R In Worksheets("Sheet1").Rows("4:10")
R.Hidden = Not R.Hidden
Next

Rick


"pgarcia" wrote in message
...
Hello all,
If rows a4-a10 are hidden, then un-hide, but if they are un-hidden, then
hide.
Looking for a VB.

Thanks.




Rick Rothstein \(MVP - VB\)[_2662_]

If then, hidden rows
 
That seems to be simply unhiding all the hidden rows in that range for me;
it does seem to hide the currently unhidden ones. Are you seeing it work
differently than that?

Rick


"Bob Phillips" wrote in message
...

With Rows("4:10")

.Hidden = Not .Hidden
End With

--
__________________________________
HTH

Bob

"pgarcia" wrote in message
...
Hello all,
If rows a4-a10 are hidden, then un-hide, but if they are un-hidden, then
hide.
Looking for a VB.

Thanks.





Rick Rothstein \(MVP - VB\)[_2664_]

If then, hidden rows
 
Actually, in looking at it closer, it seem to be setting the Hidden property
of the entire range to the opposite of what Row 4's (the first row in the
range's) Hidden property is set to.

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
That seems to be simply unhiding all the hidden rows in that range for me;
it does seem to hide the currently unhidden ones. Are you seeing it work
differently than that?

Rick


"Bob Phillips" wrote in message
...

With Rows("4:10")

.Hidden = Not .Hidden
End With

--
__________________________________
HTH

Bob

"pgarcia" wrote in message
...
Hello all,
If rows a4-a10 are hidden, then un-hide, but if they are un-hidden, then
hide.
Looking for a VB.

Thanks.







All times are GMT +1. The time now is 09:59 AM.

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