X Marks the Spot Question

Grimm127

Board Regular
Joined
Aug 17, 2011
Messages
118
I have a range of columns. Starting at Column C to AA. Each Column header is based an Calendar month This year and last year with a total at each end.

I would like in Row 5 to Mark an "X" value in each Cell that I want to Keep and blank on any other that will update each month.

For Example
If I select Jan-2021, I want mark row 5 with an " X" in Columns Jan-2021, Dec-2020, Nov-2020, Oct-2020 and Jan-2020
If I select Feb-2021, I want mark row 5 with an " X" in Columns Feb-2021, Jan-2021, Dec-2020, Nov-2020 and Feb-2020
If I select Mar-2021, I want mark row 5 with an " X" in Columns Mar-2021, Feb-2021, Jan-2021, Dec-2020 and Mar-2020
If I select Apr-2021, I want mark row 5 with an " X" in Columns Apr-2021, Mar-2021, Feb-2021, Jan-2021 and Apr-2020
If I select May-2021, I want mark row 5 with an " X" in Columns May-2021, Apr-2021, Mar-2021, Feb-2021 and May-2020
If I select Jun-2021, I want mark row 5 with an " X" in Columns Jun-2021, May-2021, Apr-2021, Mar-2021 and Jun-2020

In a nut shell, Based on my selection, mark an x on that selection and the previous three months and the same period last year.

This will be used to hide the columns that have no "X" in place (I already have the code).

It doesn't necessarily need to be done in a VBA code. A formula can work as well. I just don't have any ideas. Can you GUru's help?

Thank you!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

mrshl9898

Well-known Member
Joined
Feb 6, 2012
Messages
1,778
Is Jan-2021 a numerical value (date formatted as Mmm-YYYY? Or is it a string?
 

mrshl9898

Well-known Member
Joined
Feb 6, 2012
Messages
1,778
Assuming the Headers are in Row 1 and you select from F10. Try in C5 (copied across):

=IF(C1=$F$10,"X",IF(EDATE($F$10,-1)=C1,"X",IF(EDATE($F$10,-2)=C1,"X",IF(EDATE($F$10,-3)=C1,"X",IF(EDATE($F$10,-12)=C1,"X","")))))
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,129,803
Messages
5,638,444
Members
417,025
Latest member
MusterDuster

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
Top