Hide/Unhide Ranges

Snoopie

New Member
Joined
Mar 20, 2019
Messages
5
Hello All,

Seeking some assistance, thanks in advance to anyone that can assist !

I placed 5x Radio Buttons to use for filtering the ranges of data i have.
Range1 = 14-33
Range2 = 37-56
Range3 = 60-79
Range4 = 83-102
I also have a header range of 1-13 which must always be visible.

When i select the radio button i must click it again to disable the selection before i can choose another, i was of the understanding that the radio button reset the existing selection when you select another?

Here's my code:
Sub OptionButton15_Click()
Range("34:1000").EntireRow.Hidden = Not Range("34:1000").EntireRow.Hidden
End Sub
Sub OptionButton16_Click()
Range("14:36,57:1000").EntireRow.Hidden = Not Range("14:36,57:1000").EntireRow.Hidden
End Sub
Sub OptionButton17_Click()
Range("14:59,80:1000").EntireRow.Hidden = Not Range("14:59,80:1000").EntireRow.Hidden
End Sub
Sub OptionButton18_Click()
Range("14:82,103:1000").EntireRow.Hidden = Not Range("14:82,103:1000").EntireRow.Hidden
End Sub
Sub OptionButton19_Click()
Range("1000:1001").EntireRow.Hidden = Not Range("1000:1001").EntireRow.Hidden
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Hi there. You say
i was of the understanding that the radio button reset the existing selection when you select another
I'm not sure exactly what you mean here, but clicking a button will always just execute the code associated with it. As you have overlapping ranges and are using a toggle effect you will get some strange results. Why not replace the code in each with something like this (OptionButton15 shown):
Code:
Sub OptionButton15_Click()
Range("14:1001").EntireRow.Hidden = True
Range("14:36,57:1000").EntireRow.Hidden = False
End Sub
I assume you just want to see the ranges you have selected, but if instead you want to only see the other rows, just replace the true and false with false and true.
 
Upvote 0
This was my final code which works great.
Now i just need to have it scroll to the top each time a selection is made.
Thanks for your help @jmacleary.

Code:
Sub OptionButton15_Click()
Worksheets("mysheet").Range("1:1000").EntireRow.Hidden = False
End Sub
Sub OptionButton16_Click()
Worksheets("mysheet").Range("34:1000").EntireRow.Hidden = True
Worksheets("mysheet").Range("1:13,14:33").EntireRow.Hidden = False
End Sub
Sub OptionButton17_Click()
Worksheets("mysheet").Range("14:36,57:1000").EntireRow.Hidden = True
Worksheets("mysheet").Range("1:13,37:56").EntireRow.Hidden = False
End Sub
Sub OptionButton18_Click()
Worksheets("mysheet").Range("14:59,80:1000").EntireRow.Hidden = True
Worksheets("mysheet").Range("1:13,60:79").EntireRow.Hidden = False
End Sub
Sub OptionButton19_Click()
Worksheets("mysheet").Range("14:82,103:1000").EntireRow.Hidden = True
Worksheets("mysheet").Range("1:13,83:102").EntireRow.Hidden = False
End Sub
 
Upvote 0
Which I now managed to solve with:

Code:
Sub OptionButton15_Click()
Worksheets("Mako").Range("1:1000").EntireRow.Hidden = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
End Sub
Sub OptionButton16_Click()
Worksheets("Mako").Range("34:1000").EntireRow.Hidden = True
Worksheets("Mako").Range("1:13,14:33").EntireRow.Hidden = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
End Sub
Sub OptionButton17_Click()
Worksheets("Mako").Range("14:36,57:1000").EntireRow.Hidden = True
Worksheets("Mako").Range("1:13,37:56").EntireRow.Hidden = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
End Sub
Sub OptionButton18_Click()
Worksheets("Mako").Range("14:59,80:1000").EntireRow.Hidden = True
Worksheets("Mako").Range("1:13,60:79").EntireRow.Hidden = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
End Sub
Sub OptionButton19_Click()
Worksheets("Mako").Range("14:82,103:1000").EntireRow.Hidden = True
Worksheets("Mako").Range("1:13,83:102").EntireRow.Hidden = False
ActiveWindow.ScrollColumn = 1
ActiveWindow.ScrollRow = 1
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,152
Members
453,021
Latest member
Justyna P

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