Colorize a few cells by choosing a specific date (VBA or Conditional formatting)

Schturman

Board Regular
Joined
May 28, 2022
Messages
63
Office Version
  1. 2019
Platform
  1. Windows
Hi
How I can do this ?
For example, if I click / choose a date 11/04 in a range D2:J7, it should colorize the same date (and descriptions in 2 near cells) and same color in a range L2:N15 if the same date exist in column L.
Is it possible by VBA or Conditional formatting?
Thanks

1681308853108.png
 
Last edited:

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi @Schturman. Thanks for posting on the forum.

We need to put the format conditions and a little code in VBA to make it work automatically.

Use the following 2 conditional formats:
varios 12abr2023.xlsm
ABCDEFGHIJKLMN
1DEFGHIJLMN
226-mar27-mar28-mar29-mar30-mar31-mar01-abr05-abrsdsd
302-abr03-abr04-abr05-abr06-abr07-abr08-abr06-abrsdsd
409-abr10-abr11-abr12-abr13-abr14-abr15-abr07-abrsdsd
516-abr17-abr18-abr19-abr20-abr21-abr22-abr08-abrsdsd
623-abr24-abr25-abr26-abr27-abr28-abr29-abr09-abrsdsd
730-abr01-may02-may03-may04-may05-may06-may10-abrsdsd
811-abrsdsd
912-abrsdsd
1018-abrsdsd
1125-abrsdsd
1225-abrsdsd
Hoja5
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:N12Expression=$L2=INDIRECT(CELL("address"))textNO
D2:J7Expression=ADDRESS(ROW(),COLUMN())=CELL("address")textNO


In the sheet events, put the following code:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Application.ScreenUpdating = True
End Sub
NOTE SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.


Example:
1681313894998.png



--------------
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
--------------
 
Upvote 1
Solution
Hi @Schturman. Thanks for posting on the forum.

We need to put the format conditions and a little code in VBA to make it work automatically.

Use the following 2 conditional formats:
varios 12abr2023.xlsm
ABCDEFGHIJKLMN
1DEFGHIJLMN
226-mar27-mar28-mar29-mar30-mar31-mar01-abr05-abrsdsd
302-abr03-abr04-abr05-abr06-abr07-abr08-abr06-abrsdsd
409-abr10-abr11-abr12-abr13-abr14-abr15-abr07-abrsdsd
516-abr17-abr18-abr19-abr20-abr21-abr22-abr08-abrsdsd
623-abr24-abr25-abr26-abr27-abr28-abr29-abr09-abrsdsd
730-abr01-may02-may03-may04-may05-may06-may10-abrsdsd
811-abrsdsd
912-abrsdsd
1018-abrsdsd
1125-abrsdsd
1225-abrsdsd
Hoja5
Cells with Conditional Formatting
CellConditionCell FormatStop If True
L2:N12Expression=$L2=INDIRECT(CELL("address"))textNO
D2:J7Expression=ADDRESS(ROW(),COLUMN())=CELL("address")textNO


In the sheet events, put the following code:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  Application.ScreenUpdating = True
End Sub
NOTE SHEET EVENT
Right click the tab of the sheet you want this to work, select view code and paste the code into the window that opens up.


Example:
View attachment 89524


--------------
Let me know the result and I'll get back to you as soon as I can.
Sincerely
Dante Amor
--------------
Wow, thank you very much !!! It working perfectly !!!
I changed a little bit a conditional formatting and used only one line, because I don't want to colorize the dates in a range D2:J7, because it's already have colors related to the holidays and I wanted to use the same colors in a range L2:N15.
I used it like this, related to the holidays (religions, national etc..)
1681319138723.png


1681318988835.png


Thank you !
 
Upvote 1

Forum statistics

Threads
1,224,817
Messages
6,181,149
Members
453,021
Latest member
Justyna P

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