Hiding Rows

MissOctober

New Member
Joined
May 24, 2018
Messages
16
I have rows (18:42) which is 25 rows.

i want to use a commandbutton that use
a. two ranges:one will cover the rows starting at 18 to the last hidden row, the other will not be set
b. Use a For Each loop to go through each row in the first range using the second range as the “each” item (i.e. For Each Range2 In Range1)
c. If the row (Range2) being checked is hidden set it to shown and then exit the loop
d. If the row is already shown go to the next row (Next Range2)

so when you click the button it would show row 18 and when u click again it will show the next row while the other rows are hidden



so would my code be like

Option Explicit
Private Sub CommandButton1_Click()
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">Rows("18:42").Select

If Rows("18:42").Hidden =TrueThen
Selection
.EntireRow.Hidden =False
Else
Selection
.EntireRow.Hidden =True
EndIf</code>End Sub

https://unsee.cc/c831aaa4/
 
Last edited:

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
How about
Code:
   With Range("A17:A42").SpecialCells(xlVisible).Areas(1)
      .Offset(.Count).Resize(1).EntireRow.Hidden = False
   End With
 
Upvote 0
How about
Code:
   With Range("A17:A42").SpecialCells(xlVisible).Areas(1)
      .Offset(.Count).Resize(1).EntireRow.Hidden = False
   End With



even when i put the correct code in. it isn't working :(

this what i got:

Private Sub CommandButton1_Click()


With Range("19:42").SpecialCells(xlVisible).Areas(1)
.Offset(.Count).Resize(1).EntireRow.Hidden = False
End With


End Sub
 
Upvote 0
The code I supplied was the correct code, based on your op. ;)
If row 18 can be hidden then the code needs to include row 17 to prevent errors.
Did you try my code?
 
Upvote 0
The code I supplied was the correct code, based on your op. ;)
If row 18 can be hidden then the code needs to include row 17 to prevent errors.
Did you try my code?

this what i did. i had click on format to hide the selected rows from 19:42 and when i click on the button its doing what i wanted
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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