conditional formatting for individual byte in data string?

CreativeUsername

Board Regular
Joined
Mar 11, 2017
Messages
52
I tried to post this earlier but I think something went wrong. I have a question regarding a VBA possibility or capability.

I have the following data layout Created by hand. Is it possible to create it through VBA?

A B C D <---- columns
[TABLE="width: 472"]
<tbody>[TR]
[TD]1/15/2017[/TD]
[TD]1/13/2018[/TD]
[TD] 21100000001001000000BBBB[/TD]
[TD] 3/7/2018[/TD]
[/TR]
</tbody>[/TABLE]

I need the date in column "D" minus 1 month for 24 months counting backward to be checked against the first two dates.

If that date falls between those dates then I need the count of that month from the values in "D" of the characters in "C" to be turned red.

So above the dates 2/7/18 and 1/7/18 both fall between 1/15/17 and 1/13/18 and so the first two characters are red.

Can this be done in VBA?
 
Last edited:

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
An example:

Code:
Sub RedText()
Dim i%, dt As Date, y%, mon%, ds As Date
dt = [d14]                                      ' cell D14
mon = Month(dt)
y = Year(dt)
For i = 1 To 24
    mon = mon - 1
    If mon = 0 Then
        mon = 12
        y = y - 1
    End If
    ds = DateSerial(y, mon, Day(dt))
    If ds > [a14] And ds < [b14] Then _
    [c14].Characters(i, 1).Font.Color = vbRed
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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