VBA: Highlight row within range if a date is a weekend or based on cell value

IIII

New Member
Joined
Jan 26, 2021
Messages
18
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Hi,

I'm looking to find a way to highlight rows within this range (not entire row), based on the following two conditions:

  1. If any date in column A is a weekend, then highlight that particular row and/or
  2. If any cell value in Column B at min. contains the word "TEST" (doesn't have to match case) then highlight that particular row.
Example of output:
Book2
ABCDE
1DateShiftHoursKmsStatus
2Wednesday, 6 April 2022Jane Doey12334Approved
3Wednesday, 6 April 2022Jane Doey12334Approved
4Thursday, 7 April 2022TEST EAGLES12334Approved
5Thursday, 7 April 2022Alice Doey12334Approved
6Friday, 8 April 2022Jane Doey12334Approved
7Saturday, 9 April 2022TEST EAGLES12334Approved
8Saturday, 9 April 2022Derek Doey12334Approved
9Monday, 11 April 2022Jane Doey12334Approved
10Monday, 11 April 2022TEST EAGLES12334Approved
11Tuesday, 12 April 2022Jane Doey12334Approved
12Wednesday, 13 April 2022Steve Doey12334Approved
13Wednesday, 13 April 2022Jane Doey12334Approved
14Thursday, 14 April 2022Jane Doey12334Approved
15Thursday, 14 April 2022John Doey12334Approved
16Friday, 15 April 2022John Doey12334Approved
17Saturday, 16 April 2022John Doey12334Approved
Sheet1


I'm able to highlight the individual cells easy enough for the second condition but just can't seem to get my head around doing the rest.

Thanks in advance for any help provided and please let me know if further info is required.

Cheers.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
How about
++Fluff.xlsm
ABCDE
1DateShiftHoursKmsStatus
206/04/2022Jane Doey12334Approved
306/04/2022Jane Doey12334Approved
407/04/2022TEST EAGLES12334Approved
507/04/2022Alice Doey12334Approved
608/04/2022Jane Doey12334Approved
709/04/2022TEST EAGLES12334Approved
809/04/2022Derek Doey12334Approved
911/04/2022Jane Doey12334Approved
1011/04/2022TEST EAGLES12334Approved
1112/04/2022Jane Doey12334Approved
1213/04/2022Steve Doey12334Approved
1313/04/2022Jane Doey12334Approved
1414/04/2022Jane Doey12334Approved
1514/04/2022John Doey12334Approved
1615/04/2022John Doey12334Approved
1716/04/2022John Doey12334Approved
Test
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:E17Expression=ISNUMBER(SEARCH("test",$B2))textNO
A2:E17Expression=WEEKDAY($A2,2)>5textNO
 
Upvote 0
Hi @Fluff - Thank you for your response. I was hoping to get that same solution using VBA.

Apologies if that wasn't clear in my initial post.

Cheers.
 
Upvote 0
In that case just use the macro recorder as you add the CF rules & you will have the code.
 
Upvote 0
Solution
In that case just use the macro recorder as you add the CF rules & you will have the code.

Ahh fair enough - not sure why I didn't think of that. Cheers.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0
Try it
1653914333272.png

and
1653914375282.png
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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