Group and UnGroup columns based on user input of a current date

heyBrooker

New Member
Joined
Aug 16, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
  2. Web
I have a spreadsheet that have pay period dates, that run from V5 to AT5. We have the past pay months within 1 month grouped together and the future months within 1 month grouped together. For instance this month is August, so all the columns with dates in July, August, and September are not grouped, but all others are grouped. I have set up a user input for the numerical of the month that returns to a variant. The cells with the dates are formatted as dates dd-mm-yyyy. I have the previous groupings ungrouped and unhidden, but now I'm stuck.

Dim Cur_Month As Variant 'holds current month
Dim Col_PP As Range 'to ungroup the range V:AT columns

Cur_Month = InputBox("What month are you working with? Please enter the numerical for the month", "Choose Current Month", Month(Date))

'Selects, ungroups, and unhides the pay period section
Set Col_PP = Range("V:AT")
Col_PP.Select
Col_PP.Ungroup
Col_PP.EntireColumn.Hidden = False
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,215,069
Messages
6,122,953
Members
449,095
Latest member
nmaske

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