Function button: Unhide cells between values and hide all other
Solved/Closed
MartaGH
Posts
2
Registration date
Monday January 23, 2017
Status
Member
Last seen
January 25, 2017
-
Jan 23, 2017 at 04:19 PM
MartaGH Posts 2 Registration date Monday January 23, 2017 Status Member Last seen January 25, 2017 - Jan 25, 2017 at 02:04 PM
MartaGH Posts 2 Registration date Monday January 23, 2017 Status Member Last seen January 25, 2017 - Jan 25, 2017 at 02:04 PM
Related:
- Function button: Unhide cells between values and hide all other
- At button - Guide
- Ps3 controller reset button - Guide
- Where is the subtitle button on lg remote - Guide
- How to answer call with volume button android - Guide
- New outlook refresh button - Guide
2 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Updated by TrowaD on 24/01/17 at 12:03 PM
Updated by TrowaD on 24/01/17 at 12:03 PM
Hi Marta,
Where is your question?
You are in need of a macro and then provide that macro.
You say that you will apply that macro to other sections, but since that part of the macro is missing, I'm guessing that is where you are stuck.
Try using keywords that end with a number.
You can then replace the number with a variable and use it in a loop.
Keywords
Top1
Bottom1
Variable
x=1
Rough code sample
Do
"Top" & x Combine keyword with variable
"Bottom" & x
x=x+1 Increase variable
Loop Until x=Highest x value
Hopefully this points you in the right direction.
Best regards,
Trowa
Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.
Where is your question?
You are in need of a macro and then provide that macro.
You say that you will apply that macro to other sections, but since that part of the macro is missing, I'm guessing that is where you are stuck.
Try using keywords that end with a number.
You can then replace the number with a variable and use it in a loop.
Keywords
Top1
Bottom1
Variable
x=1
Rough code sample
Do
"Top" & x Combine keyword with variable
"Bottom" & x
x=x+1 Increase variable
Loop Until x=Highest x value
Hopefully this points you in the right direction.
Best regards,
Trowa
Monday, Tuesday and Thursday are usually the days I'll respond. Bear this in mind when awaiting a reply.
MartaGH
Posts
2
Registration date
Monday January 23, 2017
Status
Member
Last seen
January 25, 2017
Jan 25, 2017 at 02:04 PM
Jan 25, 2017 at 02:04 PM
Hello,
I found the answer. This is the macro I created. Thank you Trowa for your response!
Sub MaTes()
Rows("8:1000").EntireRow.Hidden = True
Dim Index As Integer: Index = 9
Dim I As Integer
Dim Sheet As Worksheet: Set Sheet = ThisWorkbook.Worksheets(1)
For Index = 1 To 1000
If Sheet.Cells(Index, 1).Value2 = "T*MaTes" Then
I = Index + 1
For I = Index To 1000
If Sheet.Cells(I, 1).Value2 = "U*Fin" Then
Sheet.Range(Sheet.Rows(Index), Sheet.Rows(I)).EntireRow.Hidden = False
Exit For
Else: I = I + 1
End If
Next
Else: Index = Index + 1
End If
Next
For Index = 1 To 1000
If Sheet.Cells(Index, 1).Value2 = "A*Sum" Then
I = Index + 1
For I = Index To 1000
If Sheet.Cells(I, 1).Value2 = "T*Mates" Then
Sheet.Range(Sheet.Rows(Index), Sheet.Rows(I)).EntireRow.Hidden = True
Exit For
Else: I = I + 1
End If
Next
Else: Index = Index + 1
End If
Next
End Sub
I found the answer. This is the macro I created. Thank you Trowa for your response!
Sub MaTes()
Rows("8:1000").EntireRow.Hidden = True
Dim Index As Integer: Index = 9
Dim I As Integer
Dim Sheet As Worksheet: Set Sheet = ThisWorkbook.Worksheets(1)
For Index = 1 To 1000
If Sheet.Cells(Index, 1).Value2 = "T*MaTes" Then
I = Index + 1
For I = Index To 1000
If Sheet.Cells(I, 1).Value2 = "U*Fin" Then
Sheet.Range(Sheet.Rows(Index), Sheet.Rows(I)).EntireRow.Hidden = False
Exit For
Else: I = I + 1
End If
Next
Else: Index = Index + 1
End If
Next
For Index = 1 To 1000
If Sheet.Cells(Index, 1).Value2 = "A*Sum" Then
I = Index + 1
For I = Index To 1000
If Sheet.Cells(I, 1).Value2 = "T*Mates" Then
Sheet.Range(Sheet.Rows(Index), Sheet.Rows(I)).EntireRow.Hidden = True
Exit For
Else: I = I + 1
End If
Next
Else: Index = Index + 1
End If
Next
End Sub