Formula or VBA code to format certain cells based on the value.

Seeker2025

New Member
Joined
Feb 2, 2025
Messages
11
Office Version
  1. 365
Platform
  1. Windows
Good day to everyone!

I am looking for a formula that will apply conditional formatting to a certain based on the value in that cell.

I want to create a job pickup time tracker for three shifts in each sheet each day, each with different operators, and upon the duration of the job and the region number of cells to be highlighted.

Example1

Operator-1 picks a 1-hour duration job, and the job is from the UK region

The value I enter is 1-UK1234 were

1 is the 1-hour duration of the job
UK - Is the UK region code
1234 - Is the Job ID which is not standard

Then four cells to be highlighted considering each cell a 15-minute duration.

I have also attached the template and given sample data in this and manually highlighted the cells

But I would like to have a VBA code to highlight as many cells depend on the duration and region.

Pls, refer to my attached screenshot. I wanted to attach the excel workbook, but I think only screenshot I can attach.

I want green color for the UK region jobs, Blue for the US region jobs, Orange for the AP region jobs, Yellow for Break, and Red for Leave.

Cheers.
 

Attachments

  • Screen.png
    Screen.png
    140.3 KB · Views: 20
Yes, all the three questions were relevant.

However, my boss has not yet asked for these conditions to be implemented.

It would be a great help if you could also implement those conditions.

or at least questions 2 and 3.
I have looked at all 3 but I have not been able to come up with anything feasible so far for the first case (one job interrupts another job)
Even what I am suggesting below for the second two circumstances may come unstuck.
For example in row 3, if yet another 0.5BR was inserted at, say, column P that would cause the original UK job to spill onto the US job in column T, triggering the first circumstance I asked about earlier and for which my CF is not designed. The CF would fail.
Anyway, see if this is any use for the other two conditions.
With these CF rules, the order is relevant. Enter the bottom one first and work your way up. If they end up in the wrong order you can rearrange them with Conditional Formatting -> Manage Rules by selecting a rule and using the up/down arrows

1739170486888.png


Seeker2025_2.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAABACADAEAFAG
3Name13-UK99990.5BR0.5BR0.25L0.5-US45630.25BR
4Name21.5-US3330.75L0.5BR1BR
5Name30.5-AP6661.5-AP43211BR
6Name4L
7Name5L3-US9999
8Name60.75L3-US9999
9Name7
Mon
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B3:AG20Expression=LET(last,LOOKUP("zzz",$B3:B3),IF(last="L",1,AND(RIGHT(last,1)="L",COLUMNS($B:B)-XMATCH(last,$B3:B3,,-1)<LEFT(last,LEN(last)-1)*4)))textNO
B3:AG20Expression=LET(last,LOOKUP("zzz",$B3:B3),AND(RIGHT(last,2)="BR",COLUMNS($B:B)-XMATCH(last,$B3:B3,,-1)<LEFT(last,LEN(last)-2)*4))textNO
B3:AG20Expression=LET(lp,XMATCH("*-UK*",$B3:B3,2,-1),last,INDEX($B3:B3,lp),d,$B3:B3,brl,SUM(--SUBSTITUTE(FILTER(d,(RIGHT(d,2)="BR")*(COLUMN(d)>lp),"0BR"),"BR",""))+SUM(--SUBSTITUTE(FILTER(d,(RIGHT(d,1)="L")*(COLUMN(d)>lp),"0L"),"L","")),AND(COLUMNS($B:B)-lp<(TEXTBEFORE(last,"-")+brl)*4))textNO
B3:AG20Expression=LET(lp,XMATCH("*-US*",$B3:B3,2,-1),last,INDEX($B3:B3,lp),d,$B3:B3,brl,SUM(--SUBSTITUTE(FILTER(d,(RIGHT(d,2)="BR")*(COLUMN(d)>lp),"0BR"),"BR",""))+SUM(--SUBSTITUTE(FILTER(d,(RIGHT(d,1)="L")*(COLUMN(d)>lp),"0L"),"L","")),AND(COLUMNS($B:B)-lp<(TEXTBEFORE(last,"-")+brl)*4))textNO
B3:AG20Expression=LET(lp,XMATCH("*-AP*",$B3:B3,2,-1),last,INDEX($B3:B3,lp),d,$B3:B3,brl,SUM(--SUBSTITUTE(FILTER(d,(RIGHT(d,2)="BR")*(COLUMN(d)>lp),"0BR"),"BR",""))+SUM(--SUBSTITUTE(FILTER(d,(RIGHT(d,1)="L")*(COLUMN(d)>lp),"0L"),"L","")),AND(COLUMNS($B:B)-lp<(TEXTBEFORE(last,"-")+brl)*4))textNO
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.

Forum statistics

Threads
1,226,439
Messages
6,191,046
Members
453,635
Latest member
nathanw90

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