Macro to bold, highlight & change font color of certain cells in a column

afterdinnerspeaker

Board Regular
Joined
Jan 10, 2019
Messages
70
MACRO TO BOLD, HIGHLIGHT & CHANGE FONT COLOR OF CERTAIN CELLS IN A COLUMN


I’m embarrassed to say how long I’ve been searching for an answer to the following problem:

The last column(“H”) on my spreadsheet contains the numeric totals of expenses in each row.
There are also spaces between some rows (blank cells).

Cells in that column are either zeros (0.00) or contain a number greater than zero or they’re blank.

My purpose is to find these specific totals to BOLD, highlight & change font color.



COLUMN “H”

Balance

0.00

0.00
6,638.84
15,250.15
43,193.79 ß--------


0.00
4,800.00 ß--------

0.00

0.00

0.00

0.00


0.00


Many thanks in advance for any help you can give me!
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Sorry to have missed mentioning the search criteria:

* cells must be greater than zero
* cells must be followed by at least one blank space

OBJECT IS TO REFORMAT ONLY GRAND TOTALS
 
Upvote 0
Welcome to the MrExcel board!

Try this in a copy of your workbook. It assumes that those values in column H are the results of formulas.
Code:
Sub Format_Totals_v1()
  Dim rA As Range
  
  For Each rA In Range("H2", Range("H" & Rows.Count).End(xlUp)).SpecialCells(xlFormulas, xlNumbers).Areas
    With rA.Cells(rA.Cells.Count)
      If .Value > 0 Then
        With .Font
          .Bold = True
          .Color = vbRed
        End With
        .Interior.Color = vbYellow
      End If
    End With
  Next rA
End Sub
 
Last edited:
Upvote 0
Does this macro work for you...
Code:
[table="width: 500"]
[tr]
	[td]Sub Format_GrandTotals()
  Dim Ar As Range
  For Each Ar In Range("F2", Cells(Rows.Count, "F").End(xlUp)).SpecialCells(xlFormulas, xlTextValues).Areas
    With Ar(1).Offset(-1)
      .Font.Bold = Val(.Value) > 0
      If .Font.Bold Then
        .Font.Color = vbRed
        .Interior.Color = vbYellow
      End If
    End With
  Next
End Sub[/td]
[/tr]
[/table]
 
Upvote 0
Thanks Rick! Unfortunately, I still get the same run-time error '1004' (No cells were found).

The column is actually "H" so I changed the "F" to "H" but still got the error. My column "H" is no more than 300 rows long (not sure if that makes any difference).

Many thanks, Jerry
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,180
Members
453,021
Latest member
Justyna P

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