Conditional Formatting question & AND/IF

SBennett212

New Member
Joined
Jul 29, 2017
Messages
5
Hi Forum....

I have a Conditional Formatting question regarding a doc...I updated a pic.

Apparently, that is not the info that is needed. I think I need to use an AND/ IF Function but don't know the formula...

The question is: IF the ID# has the same Service_Type with 7 days of Date of Service (DOS) then the entire row should be highlighted.

As you can see in the pic, ID# "8000-323" had Service Type "IN" on DOS "July 15". Then, ID# "8000-323" had Service Type "EX" on DOS "July 18" but had had Service Type "IN" on "July 12". Within the scenario, I need for 8000-323 to be highlighted on July 15 & July 12 to let us know that the same thing was done with on 7 days.

Can someone help me out here? Thanks.

a9x09h.jpg
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
This is one way to do accomplish what you are looking for.

Code:
=COUNTIFS($C:$C,$C3,$B:$B,$B3,$D:$D,">="&$D3-7,$D:$D,"<"&$D3+7)>1

Hope this helps.
 
Upvote 0
Wow! Amazing!! I don't understand the formula but yes, it helps A LOT. Thank you sooooooo much. I had posted this dilemma and you are the first AND only person that posted a response. I even emailed Excel people I saw on YouTube and nothing! LOL. You are a genius...now to look up and refresh what COUNTIFS is...I think I may be using lots in the future. Thanks again...You are a rock star! :):cool::grin:
 
Upvote 0
I'm glad the formula helped you out. I know the formula looks daunting but it really isn't very complicated. I will separate it by dashes to better explain it. (Also note that this formula was not available on Excel versions before Excel 2007.)

=COUNTIFS($C:$C, $C3, ---------------- $B:$B, $B3,---------------- $D:$D, ">="&$D3-7, ------------------ $D:$D, "<"&$D3+7) --------- >1
The COUNTIFS formula returns a count based upon multiple criteria. In the formula, you will have multiple sets of criteria with the criteria range listed first, then a comma and then the actual criteria. Each set of criteria is separated by a comma also.

In the formula above, the first criteria is $C:$C, $C3 which is looks at everything in column C ($C:$C) that equals whatever is in cell $C3. (In this case, it's the ID#)

The next criteria is $B:$B, $B3 which looks at everything in column B ($B:$B) that equals whatever is in cell $B3. (In this case, it';s the Service Type).

The next 2 criteria are looking at the date range. The first one of those is $D:$D, ">="&$D3-7 which looks at column D ($D:$D) and counts anything that is greater than or equal to 7 days less than the date in cell D3. (July 15th is in cell D3 so the count is anything greater than or equal to July 8th.)

The last of the COUNTIF criteria is $D:$D, "<"&$D3+7 which looks at column D ($D:$D) and counts anything that is less than 7 days greater than the date in cell $D3. (July 15th is in cell D3 so the count is anything less than July 22nd.)

Keep in mind, for a count to register, all of the 4 criteria must be met.

The last part of the formula is >1. (This is not part of the COUNTIFS formula but rather is just comparing the results of the COUNTIFS formula.) This simply means if the count returned by the COUNTIFS formula is greater than 1 then the conditional formatting will apply. (Which I assume you already know since you are working with conditional formatting already.) So, in your example, row 3 and row 8 would return counts of 2 and therefore would qualify for the conditional formatting. All other rows would return a count of 1 and not qualify for the conditional formatting.

I'm sure you are aware, but the $ character in the formula is just there to "lock down" the cell/column/row references so that when they are copied to other cells/columns/rows, the row & column numbers & letters will or won't change accordingly. When I see a formula with the $, I associate it with the word "always". So, $D3 would mean always column D but not always row 3. If the formula is copied across columns, the column won't change but if it is copied to other rows the row number will change.

And lastly, don't get discouraged by not receiving a response right away. MrExcel is one of the best forums I have ever used. Occasionally, I don't get a response but more often than not, you will find someone that can help. It has helped me countless times and some of the folks here are extremely knowledgeable. What I find that helps the most in getting a response is to be as clear as possible in your question as well as posting an example. (As you did) I'm sure you will have a better experience next time.

Good Luck!
 
Upvote 0
BTW, what does the "&" mean in the formula?

The "&" is an ampersand symbol. In Excel, it is used to concatenate 2 things together. (Example: "Bob" & " " & "Smith" would equal Bob Smith) In your example, ">="&$D3-7, the ">=" means greater than or equal to and the D3-7 would be equivalent to the date 8-Jul-2017. So, together you have greater than or equal to 8-Jul-2017. The quotes around the operator >= must be there as a rule of the formula but I can't really explain why.
 
Upvote 0
The "&" is an ampersand symbol. In Excel, it is used to concatenate 2 things together. (Example: "Bob" & " " & "Smith" would equal Bob Smith) In your example, ">="&$D3-7, the ">=" means greater than or equal to and the D3-7 would be equivalent to the date 8-Jul-2017. So, together you have greater than or equal to 8-Jul-2017. The quotes around the operator >= must be there as a rule of the formula but I can't really explain why.

Thanks...I knew that the "&" had to do with concatenate but did not know how it pertained to the formula. Thanks again for all the help and explaining it. You should teach Excel LOL
 
Upvote 0
Thanks...I knew that the "&" had to do with concatenate but did not know how it pertained to the formula. Thanks again for all the help and explaining it. You should teach Excel LOL

You're welcome. Glad I could help.

Oh, and by the way...thanks for the vote of confidence, but there are far more qualified people to teach Excel than me. I come here more often for help than I do providing it. The MrExcel forum is a great resource.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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