Create subtotal as currency

angil0126

New Member
Joined
Apr 9, 2018
Messages
8
I have this bit of code that creates a subtotal line:

'Add Total row Job Report

Dim lastrow2 As Long

lastrow2 = Cells(Rows.Count, "I").End(xlUp).Row

Cells(lastrow2 + 2, "I").Resize(1, 31) = "=SUBTOTAL(9,I2:I" & lastrow2 & ")"
With Range("I" & lastrow2 + 2, "AM" & lastrow2 + 2).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick


End With

How can I modify it so that the numbers are in currency or $#,##0.00 format. I feel like this should be relatively easy, but I'm not getting it so I must be missing something.
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Maybe this
Remember: the macro recorder is your friend !!

Code:
Dim lastrow2 As Long
lastrow2 = Cells(Rows.Count, "I").End(xlUp).Row
Cells(lastrow2 + 2, "I").Resize(1, 31) = "=SUBTOTAL(9,I2:I" & lastrow2 & ")"
    With Range("I" & lastrow2 + 2, "AM" & lastrow2 + 2).Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .Weight = xlThick
    End With
[color=red]Range("I" & lastrow2 + 2, "AM" & lastrow2 + 2).NumberFormat = "$#,##0.00"[/color]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

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