VBA help: need all color cells in font with bold

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
883
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team,

Below are the row data and i need the same font color with Bold where ever we have cell color and once it is done i dont want cell color only font color is fine for me :)
Application only for Green ,Red and Orange :)
can we add + symbol before the number as - are already available


Book1
ABCDEFGH
1Product Awareness: Airbnb Categories47%4.0-0.52.63.25.8-3.7
2BENEFITS: Helps me find the perfect trip49%8.21.72.61.80.60.4
3INSPIRATION: Is a great way to discover new places64%6.73.77.15.15.2-1.6
4BENEFITS: Helps me experience the world in a different way54%8.35.44.53.92.7-2.9
5BENEFITS: Is good for a variety of trips57%4.94.54.43.11.1-8.0
6INSPIRATION: Offers a unique way to travel61%5.83.05.63.43.10.1
7INSPIRATION: Makes me want to travel56%7.84.55.94.95.07.1
8Brand Metrics
9Product Awareness: Aircover (End-to-end protection for Airbnb stays)10%4.20.7-0.1-0.4-2.33.6
10BENEFITS: I'd trust Airbnb to help me if something goes wrong (i.e. last-minute cancellation, issues with my accommodations, etc.)48%7.73.11.8-0.10.1-1.4
11BENEFITS: Is reliable57%8.03.86.03.81.4-1.7
12BARRIERS: Feels risky25%0.0-4.7-7.3-6.6-5.9-5.6
Sheet2
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
You could do the colour part with conditional formatting if we can understand what denotes:
Green
Orange
Red
Nothing

Or has this part been done manually.

The format with the + before the number can be done using the custom format of: +0.0;-0.0;0
 
Upvote 0
The code to change the colours would look something like below although it will make the cells hard to read in the current state.
VBA Code:
Sub test()
    Dim rng As Range, rCell As Range
    
    Set rng = Range("A1").CurrentRegion
    Set rng = rng.Offset(, 2).Resize(, 6)
    
    For Each rCell In rng.Cells
        If rCell.Interior.ColorIndex <> 15 Then
            rCell.Font.ColorIndex = rCell.Interior.ColorIndex
            rCell.Interior.ColorIndex = 0
        End If
    Next rCell
End Sub
 
Upvote 0
You could do the colour part with conditional formatting if we can understand what denotes:
Green
Orange
Red
Nothing

Or has this part been done manually.

The format with the + before the number can be done using the custom format of: +0.0;-0.0;0
Hi Geo,

I need the same font color as then one we have in cell color in excel i don't think we can do via manually :)

if yes can you please help me with this :)
 
Upvote 0
The code to change the colours would look something like below although it will make the cells hard to read in the current state.
VBA Code:
Sub test()
    Dim rng As Range, rCell As Range
  
    Set rng = Range("A1").CurrentRegion
    Set rng = rng.Offset(, 2).Resize(, 6)
  
    For Each rCell In rng.Cells
        If rCell.Interior.ColorIndex <> 15 Then
            rCell.Font.ColorIndex = rCell.Interior.ColorIndex
            rCell.Interior.ColorIndex = 0
        End If
    Next rCell
End Sub
Hi Geo,

Thank you so much for your help on this :)

I got perfect solution but can we have bold with + symbol on positive number where ever we got font color:)
 
Upvote 0
If you want the macro to do it all then maybe:
VBA Code:
Sub test()
    Dim rng As Range, rCell As Range
  
    Set rng = Range("A1").CurrentRegion
    Set rng = rng.Offset(, 2).Resize(, 6)
  
    For Each rCell In rng.Cells
        With rCell
            If .Interior.ColorIndex <> 15 Then
                .Font.ColorIndex = rCell.Interior.ColorIndex
                .Interior.ColorIndex = 0
                .Font.Bold = True
                .NumberFormat = "+0.0;-0.0;0.0"
            End If
        End With
    Next rCell
End Sub
 
Upvote 0
Solution
If you want the macro to do it all then maybe:
VBA Code:
Sub test()
    Dim rng As Range, rCell As Range
 
    Set rng = Range("A1").CurrentRegion
    Set rng = rng.Offset(, 2).Resize(, 6)
 
    For Each rCell In rng.Cells
        With rCell
            If .Interior.ColorIndex <> 15 Then
                .Font.ColorIndex = rCell.Interior.ColorIndex
                .Interior.ColorIndex = 0
                .Font.Bold = True
                .NumberFormat = "+0.0;-0.0;0.0"
            End If
        End With
    Next rCell
End Sub
Super cool :)

Thank you so much, Geo... your and team support always help us to work better in our lifestyle:)
 
Upvote 0
If you want the macro to do it all then maybe:
VBA Code:
Sub test()
    Dim rng As Range, rCell As Range
 
    Set rng = Range("A1").CurrentRegion
    Set rng = rng.Offset(, 2).Resize(, 6)
 
    For Each rCell In rng.Cells
        With rCell
            If .Interior.ColorIndex <> 15 Then
                .Font.ColorIndex = rCell.Interior.ColorIndex
                .Interior.ColorIndex = 0
                .Font.Bold = True
                .NumberFormat = "+0.0;-0.0;0.0"
            End If
        End With
    Next rCell
End Sub

Hi Geo,

Sorry for the multiple treads

just now i got an update from my team i need only red and green font to be bold and need to ignore the Orange color in excel
so for the orange color, i need the same grey pattern with white font we have in Excel.

Thank you in advance :):)
 
Upvote 0
Hi Geo,

Sorry for the multiple treads

just now i got an update from my team i need only red and green font to be bold and need to ignore the Orange color in excel
so for the orange color, i need the same grey pattern with white font we have in Excel.

Thank you in advance :):)
Maybe:
VBA Code:
Sub test()
    Dim rng As Range, rCell As Range
 
    Set rng = Range("A1").CurrentRegion
    Set rng = rng.Offset(, 2).Resize(, 6)
 
    For Each rCell In rng.Cells
        With rCell
            If .Interior.ColorIndex = 43 Or .Interior.ColorIndex = 18 Then
                .Font.ColorIndex = rCell.Interior.ColorIndex
                .Interior.ColorIndex = 0
                .Font.Bold = True
                .NumberFormat = "+0.0;-0.0;0.0"
            ElseIf .Interior.ColorIndex = 44 Then
                .Interior.ColorIndex = 15
                .Font.Color = vbWhite
            End If
        End With
    Next rCell
End Sub
 
Upvote 0
Maybe:
VBA Code:
Sub test()
    Dim rng As Range, rCell As Range
 
    Set rng = Range("A1").CurrentRegion
    Set rng = rng.Offset(, 2).Resize(, 6)
 
    For Each rCell In rng.Cells
        With rCell
            If .Interior.ColorIndex = 43 Or .Interior.ColorIndex = 18 Then
                .Font.ColorIndex = rCell.Interior.ColorIndex
                .Interior.ColorIndex = 0
                .Font.Bold = True
                .NumberFormat = "+0.0;-0.0;0.0"
            ElseIf .Interior.ColorIndex = 44 Then
                .Interior.ColorIndex = 15
                .Font.Color = vbWhite
            End If
        End With
    Next rCell
End Sub
Waw...!!! Thanks, youuuuu so much Geo for your hard work and your support on this :):)

This made my day.......... :)
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,916
Members
449,093
Latest member
dbomb1414

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