Hi,
Need help to be able to fill a col with colour if the cells match.
I have attached an example
Assistance appreciated
Hi,
Need help to be able to fill a col with colour if the cells match.
I have attached an example
Assistance appreciated
![]()
Option Explicit Sub date_colouring() Application.ScreenUpdating = False Dim count, cl For count = 1 To Range("W" & Rows.count).End(xlUp).Row If Strings.Mid(Range("D3"), 4, 7) = Strings.Mid(Range("W" & count), 4, 7) Then For Each cl In Range("D6:Q16") If DateSerial(Strings.Mid(Range("D3"), 7, 4), Strings.Mid(Range("D3"), 4, 2), cl.Value) = Range("W" & count) Then cl.Interior.ColorIndex = 37 End If Next cl End If Next count Application.ScreenUpdating = True End Sub
Thanks for that but I have tried the code in the test sheet and cannot seem to get it to work
are you are able to assist
NOTE merges cells do not mormally work very well with formulas - and so the merge cell is being seens AS D3
Select cells D8 to D16 then
Put this
=D8=DATE(YEAR($D$3),MONTH($D$3),DAY(D$6))
as a conditional format formula and enter
Now select D8:D16 and copy - select E8:Q16 and paste special > format
see attached spreadsheet update
Perhaps I am not clear in what I am after
If the date in col D is in the area D8 to q16 then only that date is to be filled
e.g. 2/12/13 the col d5 to d 16 would be coloured blue
The other date in the list is 9/12/13 so again L5 to 16 would be blue
The Grey for the Sat and Sun to remain but as indicated only the dates nominated to be filled with a colour
Hop that clarifies
Thats what the code I posted did when I tried it on the example you posted. Not sure what is different for you but it is probably to do with the date formatting.
So you were able to get the code to highlight only the col with corresponding dates in col w
Yes. It highlighted in the blue colour the dates you had listed.
no I was matching withSo you were able to get the code to highlight only the col with corresponding dates in col w
the month and year in D3 and the Days in row 6
So did not use column W and how big will column W get - probably better to stay with yudlugar VBA/Macro solutions
I cannot get the code to work on my example - attention yudlugar
I've been back and double checked, I copied the code back into the example workbook and run it, I got cell L6 highlighted in blue.
As I said earlier, if this doesn't work the most obvious problem will be to do with date formatting on our machines. Maybe try running this macro and tell me what you get in cells A1 - A4
I'll then see if I can change my code to get it to work for you![]()
sub date_formats() Range("A1") = dateserial(12,2,1) Range("A2) = Strings.Mid(Range("D3"), 4, 7) Range("A3") = Strings.Mid(Range("W8"),4, 7) Range("A4") = cl.value
Sorry I could not get back to you earlier.
No I cannot get it to work using either code
Try this regular Conditional formatting approach...
1. highlight the range you want to apply the conditional formatting to
2. on the home tab, styles, select CF
3. select new rule, select use formula
4. enter =ISNUMBER(VLOOKUP($D$3+D$6-1,$AL$6:$AL$11,1,0)) format fill the color you want
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
Many thanks that worked just fine
Appreciate the help
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks