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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.

Forum statistics

Threads
1,223,889
Messages
6,175,226
Members
452,620
Latest member
dsubash

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