How to change text color to different color after rewrite cell?

Lacan

Board Regular
Joined
Oct 5, 2016
Messages
167
Office Version
  1. 365
Platform
  1. Windows
Hello Guys,

Using VBA how can change text color to different color after rewrite text cell?

Thank you very much for the help.
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Dear @JoeMo

First, hope this post can find you well! 🍻👍

Please would like an update of your VBA Formula.
Would like that formula worked with conditional formatting inserted in table despite of the colour chosen in CF would like that returned to the parameterized colour in Formula VBA Code.
Just put first the VBA Formula and then the sheet with table.
Hope you can help?
Any questions please let know.
Thank you very much my friend!!! 🙏🙏👍

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Const colorOdd As Long = vbBlue
Const colorEven As Long = vbBlack
Static N() As Long
Dim R As Range, c As Range  'R will be the range you want to monitor for changes
Set R = Range("E4:E12")
ReDim Preserve N(1 To R.Rows.Count)
If Not Intersect(Target, R) Is Nothing Then
    For Each c In Intersect(Target, R)
        N(c.Row - R(1).Row + 1) = N(c.Row - R(1).Row + 1) + 1
        With Range("C" & c.Row, "F" & c.Row)
            If N(c.Row - R(1).Row + 1) Mod 2 = 0 Then
                With .Font
                    .Bold = False
                    .Color = colorEven
                End With
            Else
                With .Font
                    .Bold = True
                    .Color = colorOdd
                End With
            End If
        End With
    Next c
End If
End Sub

Rewrite_06-05-24.xlsm
ABCDEFG
1
201/01/2024
3NAME DATEQTDPVP
4A01/12/202325 €
5B02/05/202438 €
6C15/10/202363 €
7D04/03/2024210 €
8E04/04/2024230 €
9F01/05/2024514 €
10G10/11/20232121 €
11H30/09/20239 €
12I03/03/20242211 €
13
14
15
Folha1
 
Upvote 0
Would like that formula worked with conditional formatting inserted in table despite of the colour chosen in CF would like that returned to the parameterized colour in Formula VBA Code.
Just put first the VBA Formula and then the sheet with table.
I don't understand what you want. In the data that you show in post #22, which cells have CF? If you want the CF color changed even when the CF condition is met then CF must be removed prior to changing the color. Is that what you want?
 
Upvote 0
I don't understand what you want. In the data that you show in post #22, which cells have CF? If you want the CF color changed even when the CF condition is met then CF must be removed prior to changing the color. Is that what you want?
Hi @JoeMo
In the data that you show in post #22, which cells have CF? Accordingly with formula "=SE($D4<$D$2;1)", CF is applied to all table.
1715200897857.png

If you want the CF color changed even when the CF condition is met then CF must be removed prior to changing the color. Is that what you want?
Yes, would like to change the colour of CF to the colour of the VBA Formula "Blue" after write in Column "QTD" even if CF is met. If you test it, like the same in all other cells wich CF is not met. ( Like example in "E7", after write in it change to Blue and Bold )
Because this is a small example of an Order List is quite difficult in front of the customer to remove CF cell by cell when it is applied.
Thought that VBA would help in being more easier and fast.
If you need an example please let me know can make in another table side by side the goal results.
Thank you very much.
Here is the table.


Rewrite_06-05-24.xlsm
ABCDEFG
1
201/01/2024
3NAME DATEQTDPVP
4A01/12/202325 €
5B02/05/202438 €
6C15/10/202363 €
7D04/03/2024510 €
8E04/04/2024230 €
9F01/05/2024514 €
10G10/11/20232121 €
11H30/09/202339 €
12I03/03/20242211 €
13
14
Folha1
 
Upvote 0
If you need an example please let me know can make in another table side by side the goal results.
Yes, please give me side by side version. And please include all the CF information that XL2BB can provide for the starting table.
 
Upvote 0
Yes, please give me side by side version. And please include all the CF information that XL2BB can provide for the starting table.
Dear @JoeMo

Accordingly keeping your VBA Formula here is the goals that would like to achieve with the Examples in Table 2 and Table 3 keeping the CF on.
To explain and show the results pretended and keep it KISS just made changes in cells I5, I9 and I12 and then N5, N9 and N12 and so on.
Please let me know it need more information.
Thank you very much!!! 👍👍

Rewrite_06-05-24.xlsm
ABCDEFGHIJKLMNOP
1
2STARTING TABLERESULTS AFTER 1ST CHANGERESULTS AFTER 2ND CHANGE
301/01/202401/01/202401/01/2024
4NAME DATEQTDPVPNAME DATEQTDPVPNAME DATEQTDPVP
5A01/12/202315 €A01/12/202325 €A01/12/202335 €
6B02/05/202418 €B02/05/202418 €B02/05/202418 €
7C15/10/202313 €C15/10/202313 €C15/10/202313 €
8D04/03/2024110 €D04/03/2024110 €D04/03/2024110 €
9E04/04/2024130 €E04/04/2024230 €E04/04/2024330 €
10F01/05/2024114 €F01/05/2024114 €F01/05/2024114 €
11G10/11/2023121 €G10/11/2023121 €G10/11/2023121 €
12H30/09/202319 €H30/09/202329 €H30/09/202339 €
13I03/03/2024111 €I03/03/2024111 €I03/03/2024111 €
14
Folha1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B5:E13Expression=SE($C5<$C$3;1)textNO
 
Upvote 0
Accordingly keeping your VBA Formula here is the goals that would like to achieve with the Examples in Table 2 and Table 3 keeping the CF on.
To explain and show the results pretended and keep it KISS just made changes in cells I5, I9 and I12 and then N5, N9 and N12 and so on.
The use of CF with a function I have never seen before (SE) and do not have available on MS 365 US version complicates things enough that I think you should start a new thread with your request.
I don't know what you mean by "keeping the CF on". I don't think you can programmatically change the font color of a CF cell having a CF expression that evaluates to True unless you first remove the CF (i.e. delete the format condition).
 
Upvote 0
Dear @JoeMo 🖐

In order to help and clarify (SE) translated to US is equal to the IF function.
Yes, was thinking that would be possible to compatible both in other words through CF add one colour and VBA programmatically change the font color to a different one.
Will think if should start a new thread.
Again, thank you very much for your care and concern. 👍👍🍻
Will keep in touch.
 
Upvote 0
Dear @JoeMo 🖐

In order to help and clarify (SE) translated to US is equal to the IF function.
Yes, was thinking that would be possible to compatible both in other words through CF add one colour and VBA programmatically change the font color to a different one.
Will think if should start a new thread.
Again, thank you very much for your care and concern. 👍👍🍻
Will keep in touch.
You are welcome - thanks for the reply.
 
Upvote 0

Forum statistics

Threads
1,216,115
Messages
6,128,919
Members
449,478
Latest member
Davenil

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