Hiding rows + columns via range defined in userform input

*mikus*

New Member
Joined
Sep 9, 2005
Messages
14
My worksheet has a series of rows & corresponding columns, let's call them 'Options". Envision 20 options exist, so there's....
- 20 option columns, then
- 20 option rows
.... these are all in sequential order no spaces.

Worksheet users can manage display of these options via a simple userform where they input a start/end range to display.

Today I do this with absolute cell positions, BUT the options move around on sheet. Can anyone help me with approach or syntax to reference the positions dynamically? I have a few ideas, but can't get the code right. Was trying named ranges but can't figure out syntax using those. I'm open to any approach that works.

Here's a snippet of what I do now.
VBA Code:
    Dim Ostart As String
    Dim Oend As String

'Assign userform inputs to those....
    Ostart = USERFORM.TextBox1.Text
    Oend = USERFORM.TextBox2.Text

'some code to hide all of 1-25, nothing special

'The section I'm struggling with is this --- need to get away from the exact positions
        Range(Cells(1, 19 + Ostart), Cells(1, 19 + Oend)).EntireColumn.Hidden = False
        Range(Cells(19 + Ostart, 1), Cells(19 + Oend, 1)).EntireRow.Hidden = False

I understand compensation is a no-no but if it's allowed I'll happily donate $20 to my local animal shelter for a working result
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

Forum statistics

Threads
1,224,820
Messages
6,181,162
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