VBA for A15 cell to calculate red font values and C15 cell to calculate black font values

Status
Not open for further replies.

data808

Active Member
Joined
Dec 3, 2010
Messages
353
Office Version
  1. 2019
Platform
  1. Windows
I have a spreadsheet that users will type number values into cell range A1:C10. Then A15 and C15 will tally up the totals of these values but is there a way for cell A15 to only tally up if the font color is red within the cells of A1:C10? Then have C15 cell only tally up if the font color is black within the same cell range A1:C10?

Thanks.
 
Can you turn on your Macro Recorder and record yourself changing the font color on a cell from black-to-red and then back, from red-to-black, and then turn off the Macro Recorder?
Then, inspect the code, and see which color codes it is using.
If you have an issue deciphering the recorded code, please copy and paste it here.
I just tried this:

If Range("O1").Locked = False Then
cell.Font.Color = RGB(255, 0, 0)
Else
cell.Font.ColorIndex = RGB(0, 0, 0)
End If

Same error occurred. The RGB(255..... is for red and the RGB(0....... is for the black btw.

I think the problem may be with the "cell.Font.ColorIndex". Is there another way to tell it to use a font color in a cell?
 
Upvote 0

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Can you turn on your Macro Recorder and record yourself changing the font color on a cell from black-to-red and then back, from red-to-black, and then turn off the Macro Recorder?
Then, inspect the code, and see which color codes it is using.
If you have an issue deciphering the recorded code, please copy and paste it here.
I just recorded a macro just to make sure and this is the code that came up:

Sub test()
'
' test Macro
'

'
ActiveCell.FormulaR1C1 = "asdf"
Range("A2").Select
With Selection.Font
.Color = -16776961
.TintAndShade = 0
End With
ActiveCell.FormulaR1C1 = "asdf"
Range("A3").Select
With Selection.Font
.ColorIndex = xlAutomatic
.TintAndShade = 0
End With
ActiveCell.FormulaR1C1 = "asdf"
Range("A4").Select
End Sub
 
Upvote 0
Can you turn on your Macro Recorder and record yourself changing the font color on a cell from black-to-red and then back, from red-to-black, and then turn off the Macro Recorder?
Then, inspect the code, and see which color codes it is using.
If you have an issue deciphering the recorded code, please copy and paste it here.
I tried all kinds of things today with no luck. Even tried .ColorIndex = 3 which is red I believe and that didn't work either. I think this may be impossible which is just disappointing as it seems like such an easy problem to resolve. I also can't believe that excel doesn't have a simple setting to change the black automatic font color to another color of your choosing. To me that just seems ridiculous. I may try to post one more thread and reword the question of my post a bit to see if there is someone else out there that may have a solution for this. @Joe4 if you come up with any other ideas then please let me know. Thanks for trying.
 
Upvote 0
I gave that to you first in post #3. I would never be able to guess that color code myself.
Sorry, I answer a lot of threads, and when they begin to stretch out over multiple days, I sometimes lose where I am on them.

Do you know the color code for the font colors in cells?
No, that is why I use the Macro Recorder to do it.

Just for kicks, why not try the original solution I proposed and see if that works (before you start making all sorts of changes to things, make sure the initial one works!).
It works flawlessly for me.

I may try to post one more thread and reword the question of my post a bit to see if there is someone else out there that may have a solution for this.
Please don't do that in the future, as it is in violation of rule 12 here: Message Board Rules
Since you couldn't wait for me to respond (I am not on line 24 hours a day!), and have moved on and already gotten replies on the other thread, I am shutting this one down.

This is the other thread: VBA to change black automatic font color for future entries
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,440
Messages
6,124,882
Members
449,193
Latest member
PurplePlop

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