Oberon70
Board Regular
- Joined
- Jan 21, 2022
- Messages
- 160
- Office Version
- 365
- Platform
- Windows
I am trying to to use the below to add up a range that needs to be dynamic as different statements have different amount of transactions.
But I am Receiving the error "Run-Time error '1004': Application-defined or object-defined error.
My variables are globally defined.
Sorry about no mini sheet as I can't use add-ons when I am using my work laptop.
If needed, I will create the above on a fake spreadsheet and use mini sheet from my personal computer.
But I am Receiving the error "Run-Time error '1004': Application-defined or object-defined error.
My variables are globally defined.
VBA Code:
Sub adding()
'
' adding Macro
'
'
wb_created.Sheets("To Be Receipted").Activate
Range("E2").Select
LastRow = wb_created.Sheets("To Be Receipted").Cells(Rows.Count, 1).End(xlUp).Row
ActiveCell.Formula = "=SUM(C2:D2)"
Selection.AutoFill Destination:=Range("E2:E" & LastRow), Type:=xlFillDefault
Range("B" & (LastRow + 2)).Formula = "=SUM(B2:B " & LastRow & ")"
Range("C" & (LastRow + 2)).Formula = "=SUM(C2:C " & LastRow & ")"
Range("D" & (LastRow + 2)).Formula = "=SUM(D2:D " & LastRow & ")"
Range("E" & (LastRow + 2)).Formula = "=SUM(E2:E " & LastRow & ")"
End Sub
Sorry about no mini sheet as I can't use add-ons when I am using my work laptop.
If needed, I will create the above on a fake spreadsheet and use mini sheet from my personal computer.