Hiding columns based on cell value

kanemitchell99

New Member
Joined
Jul 24, 2018
Messages
7
Office Version
  1. 2021
Platform
  1. Windows
Hi,
I am making a project cost forecasting sheet and want to be able to hide (or populate, whichever is easier) columns based on how long the project will run for
- Enter start date of project (01/01/2024)
- Enter project length in months (say 14 months)
- Formula should hide (or populate) columns up until column J (which is 8 months)

I could frig around with lots of IF commands and conditional formatting but wondering if there is neat solution?
Thanks
 

Attachments

  • Excel Question Snip.PNG
    Excel Question Snip.PNG
    12.5 KB · Views: 23

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Please update your profile so helpers can see what version of Excel you're using (solutions will vary).
Assuming you're using 365/2021 then the following should give you what you want:

Book1
ABCDEFGHIJ
1Project start date1/01/2024
2Project length (months)8
3
4Month No12345678
5MonthJan 2024Feb 2024Mar 2024Apr 2024May 2024Jun 2024Jul 2024Aug 2024
6Area 1 Cost
7Area 1 Cost
8Area 1 Cost
9
Sheet1
Cell Formulas
RangeFormula
B4:I4B4=SEQUENCE(1,B2)
B5:I5B5=TEXT(DATE(YEAR(B1),SEQUENCE(1,B2),1),"mmm yyyy")
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:M18Expression=AND($A4<>"",A$4<>"")textNO
 
Upvote 0
Solution
Or perhaps this? (Col I not Col J?)
Format row 5 as "mmm yyyy"
Also assuming recent version with relevant functions.

24 02 21.xlsm
ABCDEFGHIJ
1Project start date1/01/2024
2Project length (months)8
3
4Month No12345678
5MonthJan 2024Feb 2024Mar 2024Apr 2024May 2024Jun 2024Jul 2024Aug 2024
Project run
Cell Formulas
RangeFormula
B4:I4B4=SEQUENCE(,B2)
B5:I5B5=EDATE(B1,B4#-1)
Dynamic array formulas.
 
Last edited:
Upvote 0
Oops, I forgot the formatting. :oops:

24 02 21.xlsm
ABCDEFGHIJK
1Project start date1/01/2024
2Project length (months)8
3
4Month No12345678
5MonthJan 2024Feb 2024Mar 2024Apr 2024May 2024Jun 2024Jul 2024Aug 2024
6Area 1 Cost
7Area 1 Cost
8Area 1 Cost
9
10
Project run
Cell Formulas
RangeFormula
B4:I4B4=SEQUENCE(,B2)
B5:I5B5=EDATE(B1,B4#-1)
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:T8Expression=COLUMNS($A:A)<=$B$2+1textNO
 
Upvote 0
Please update your profile so helpers can see what version of Excel you're using (solutions will vary).
Assuming you're using 365/2021 then the following should give you what you want:

Book1
ABCDEFGHIJ
1Project start date1/01/2024
2Project length (months)8
3
4Month No12345678
5MonthJan 2024Feb 2024Mar 2024Apr 2024May 2024Jun 2024Jul 2024Aug 2024
6Area 1 Cost
7Area 1 Cost
8Area 1 Cost
9
Sheet1
Cell Formulas
RangeFormula
B4:I4B4=SEQUENCE(1,B2)
B5:I5B5=TEXT(DATE(YEAR(B1),SEQUENCE(1,B2),1),"mmm yyyy")
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:M18Expression=AND($A4<>"",A$4<>"")textNO
Wow thank you I haven't come across the sequence function before that is brilliant!!
 
Upvote 0
Glad you got a successful outcome.

Clearly it means that you do have a recent version of Excel. It would be very helpful for the future if you did update your profile (as requested above) so we know which recent version and so that information is always available.
Click your user name at the top right of the forum, then ‘Account details’. Don’t forget to scroll down & ‘Save’ after you have entered the relevant information.

If your version is 365 then you can also get both rows of results with a single formula in cell B4.

24 02 21.xlsm
ABCDEFGHIJ
1Project start date1/01/2024
2Project length (months)8
3
4Month No12345678
5MonthJan 2024Feb 2024Mar 2024Apr 2024May 2024Jun 2024Jul 2024Aug 2024
6Area 1 Cost
7Area 1 Cost
8Area 1 Cost
Project run (2)
Cell Formulas
RangeFormula
B4:I5B4=LET(s,SEQUENCE(,B2),VSTACK(s,EDATE(B1,s-1)))
Dynamic array formulas.
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A4:T8Expression=COLUMNS($A:A)<=$B$2+1textNO
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,772
Members
452,353
Latest member
strainu

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