Show/Hide Row Range Based on Cell Value

twothings

Board Regular
Joined
Jul 9, 2011
Messages
50
Office Version
  1. 365
Platform
  1. Windows
Hello all and thank you for your assistance.

I have searched forums thoroughly for a solution to my problem without success so seek your expertise for an answer.

Situation
I have a list box with the following 13 options:

Show All
July 14
August 14
September 14
October 14
November 14
December 14
January 15
February 15
March 15
April 15
May 15
June 15

<colgroup><col></colgroup><tbody>
</tbody>

Depending on what is selected, cell C2 gets a number between 1 and 13.

In row ranges B8:B372, I have the following date ranges for a local financial year:

01/07/14
02/07/14
03/07/14
04/07/14
05/07/14
...
30/06/15

<colgroup><col></colgroup><tbody>
</tbody>


Problem
What I need to occur is the following:

If C2 = 1, all row dates show
If C2 = 2, only show July 14 dates (1/7/14-31/7/14). All other rows in range B8:B372 hide.
If C2 = 3, only show August 14 dates, others in range hide
If C2 = 4, only show Sept 14 dates, others in range hide
If C2 = 5, only show Oct 14 dates, others in range hide
...
If C2 = 13, only show June 15 dates, others in range.


Thank you for taking the time to read this and provide assistance.

Scott
 
Hi Scott,

And here is where we swear at M$. You are using a Form Control List Box, not an ActiveX ListBox (note the lack of a space in the name). Form Controls and ActiveX controls are different animals with the same (or similar) names. The form controls do not expose events to the worksheet in the same way as ActiveX controls do. If you delete the Form Control List Box and insert an ActiveX ListBox you should be on the right path.
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Thanks for that. I have implemented the new ActiveX ListBox and have it referencing cell B2 which is set to number format. Since the ListBox cell range is a date in custom format, ie. mmmm yy, the resulting linked cell result is a date in number format. ie. selecting August 14 in the listbox, results in cell B2 displaying 41852. Without becoming very complicated with cell formulas, is it possible in VBA to have the linked cell value pulled from elsewhere?

So in short, when clicking on:

Show All, cell B2 will result in 1 (instead of Show All),
July 14, cell B2 will result in 2 (instead of 41821), etc and so on.

Show All1
July 142
August 143
September 144
October 145
November 146
December 147
January 158
February 159
March 1510
April 1511
May 1512
June 1513

<colgroup><col><col></colgroup><tbody>
</tbody>


My current file is available here:

http://s000.tinyupload.com/?file_id=09932552625885224089

Thanks!
 
Upvote 0
Disregard above, I have found a quick solution using a long IF statement. All working great. Thank you to those members that provided me assistance!
 
Upvote 0
For your info the fix for the ListBox is simple. Where you have the ListBoxes Listfill range directed to a single column, change it to two columns and have 1-13 in the second column (adjacent the dates) and then set the ListBoxes BoundColumn property to 2. This way your LinkedCell gets the value from the offset column, rather than the selection.
 
Upvote 0

Forum statistics

Threads
1,215,491
Messages
6,125,102
Members
449,205
Latest member
ralemanygarcia

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