conditional format

beepetark

New Member
Joined
Nov 22, 2018
Messages
21
hello excel experts

i like to ask you that how we can do the date which occurs more than 1 time and
for different dates different colours
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
If you have a sheet named "colors", place the code below in a module. I created a sheet with the dates in column B starting in row 3 (row 1 blank; row 2 header: "dates").

Code:
Sub different_colour()
Dim lrow As Integer
lrow = Sheets("colors").Range("B" & Rows.Count).End(xlUp).Row
For N = 3 To lrow
    If Application.WorksheetFunction.CountIf(Worksheets("colors").Range("B3:B" & lrow), Worksheets("colors").Range("B" & N)) = 1 Then
    GoTo skip
    Else
    Worksheets("colors").Range("B" & N).Interior.ColorIndex = Application.WorksheetFunction.Match(Worksheets("colors").Range("B" & N), Worksheets("colors").Range("B3:B" & lrow), 0) + 2
    End If
skip: Next N
Worksheets("colors").Activate
Range("B3").Select
End Sub
 
Upvote 0
Cross posted
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

Please supply links to other sites where you have asked this question.
 
Upvote 0
If you have a sheet named "colors", place the code below in a module. I created a sheet with the dates in column B starting in row 3 (row 1 blank; row 2 header: "dates").

Excellent your macro. I liked the way you solved it.
Checking your macro and if you do not mind, I would only add a small detail. It is not necessary the "goto skip"

Code:
Sub different_colour()
Dim lrow As Integer
lrow = Sheets("colors").Range("B" & Rows.Count).End(xlUp).Row
For N = 3 To lrow
    If Application.WorksheetFunction.CountIf(Worksheets("colors").Range("B3:B" & lrow), Worksheets("colors").Range("B" & N)) [COLOR=#ff0000]> 1[/COLOR] Then
    Worksheets("colors").Range("B" & N).Interior.ColorIndex = Application.WorksheetFunction.Match(Worksheets("colors").Range("B" & N), Worksheets("colors").Range("B3:B" & lrow), 0) + 2
    End If
Next N
Worksheets("colors").Activate
Range("B3").Select
End Sub

Good job!
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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