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 rangesne 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/
i want to use a commandbutton that use
a. two rangesne 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: