0

I have a rather crude spreadsheet that tracks simple monthly data with each month in a different column. I'm hoping to create a drop down list in cell B6 or C6 which allows the user to select the appropriate month and it will filter out all of the other columns/months so they don't have to scroll across from left to right. The 'Quarterly' headers are not 'Merge and Centre' they're just 'Centre across selection' (if that makes any difference).

Thanks

enter image description here

1
  • You could reconfigure the table to have a new column with MMM-YY (vertically oriented) to the left of each set of monthly data. Then highlight a set of monthly data and use the GROUPING option on the ribbon to collapse those columns of data. Repeat for each set of monthly data. Somehwhat klunky but a possible alternative to vba.
    – bugdrown
    Commented Jul 8 at 2:13

1 Answer 1

0

This cannot be done with formulas. You will need VBA to achieve that.

Conceptually: Create the dropdown in your desired cell for the month number.

Add code for a Worksheet_Change event that does the following:

  • check that the change was the dropdown cell. If not, end the macro.
  • Hide columns F to the last column
  • use a Select Case statement with cases from 1 to 12
  • depending on the selected month number, unhide the columns that pertain to that number

You can use the macro recorder to help with the basic syntax and fine tune it to your needs.

With VBA in the mix, you will need to save the file as a macro-enabled workbook with the .xlsm extension.

Not the answer you're looking for? Browse other questions tagged or ask your own question.