X Marks the Spot Question

Grimm127

Board Regular
Joined
Aug 17, 2011
Messages
132
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

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
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","")))))
 
Upvote 0
Solution

Forum statistics

Threads
1,213,490
Messages
6,113,957
Members
448,535
Latest member
alrossman

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