NasimAnsari
New Member
- Joined
- Sep 2, 2020
- Messages
- 19
- Office Version
- 365
- 2016
- Platform
- Windows
Hello Everyone,
I would need help with the Subtotal formula to run the top column till end data with currency formula for specific columns.
Currently, I am using the below code which is not helping me
I would need help with the Subtotal formula to run the top column till end data with currency formula for specific columns.
Currently, I am using the below code which is not helping me
VBA Code:
Sub Subtotal ()
Dim Lastrow As Long
Dim LastCol As Long
With Worksheets("Trending Report")
Lastrow = .Cells(Rows.Count, "L").End(xlUp).Row
.Range("L3:L" & Lastrow).Select
LastCol = ActiveSheet.Range("L3").End(xlToLeft).Column
ActiveSheet.Range("L3", ActiveSheet.Cells(Lastrow, LastCol)).Select
End With
With Selection
ActiveSheet.Range("L3", ActiveSheet.Cells(Lastrow, LastCol)).Select
Range("L3").Select
ActiveCell.FormulaR1C1 = "=SUBTOTAL(9,R[2]C:R[999998]C)"
Selection.Copy
Range("M3:P3").Select
Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "$#,##0.00_);[Red]($#,##0.00)"
Range("L3:P3").Select
Selection.Font.Bold = True
Selection.Interior.Color = RGB(219, 219, 219)
Selection.Font.Bold = True
Selection.Font.Size = 12
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
With Selection.Font
.ColorIndex = xlAutomatic
End With
Range("L3").Select
End With
End With
Attachments
Last edited by a moderator: