i have Makro what wrong with my Code ,i want
1. autoSum in every in col B =Sub then in Range J will autoSum
2. AutoSUm in evey in Col B = TOTAL BIAYA LANGSUNG PERSONIL (a + b) then sub total 1 + sub total 2
3.AutoSum all Sub if col B= "TOTAL"
Sub MyCalculate()
Dim i, LR, c As Long: LR = Range("H" & Rows.Count).End(xlUp).Row
Dim Rng, RngSum As Range
Dim BarisAwal As Long
Dim bool As Boolean: bool = True
With Application
.DisplayAlerts = False
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
With ActiveSheet
For Each Rng In .Range("F23:F" & LR)
If .Range("F" & Rng.Row) <> "" And IsNumeric(.Range("E" & Rng.Row)) _
And IsNumeric(.Range("G" & Rng.Row)) And .Range("E" & Rng.Row) > 0 Then
If BarisAwal < 1 Then BarisAwal = Rng.Row
.Range("J" & Rng.Row & ",N" & Rng.Row).FormulaR1C1 = "=RC[-1] * RC[-3]* RC[-5]"
.Range("N" & Rng.Row).FormulaR1C1 = "=RC[-1] * RC[-3]* RC[-5]"
.Range("P" & Rng.Row).FormulaR1C1 = "=RC[-1] * RC[-7]"
.Range("R" & Rng.Row).FormulaR1C1 = "=RC[-1] * RC[-9]"
.Range("S" & Rng.Row & ",T" & Rng.Row).FormulaR1C1 = "=RC[-2] + RC[-4]"
ElseIf .Range("H" & Rng.Row) <> "" And IsNumeric(.Range("F" & Rng.Row)) And _
.Range("F" & Rng.Row) > 0 Then
.Range("J" & Rng.Row).FormulaR1C1 = "=RC[-1] * RC[-4]"
.Range("N" & Rng.Row).FormulaR1C1 = "=RC[-2] * RC[-5]"
.Range("P" & Rng.Row).FormulaR1C1 = "=RC[-1] * RC[-7]"
.Range("R" & Rng.Row).FormulaR1C1 = "=RC[-1] * RC[-9]"
.Range("S" & Rng.Row & ",T" & Rng.Row).FormulaR1C1 = "=RC[-2] + RC[-4]"
ElseIf Left(.Range("B" & Rng.Row), 3) = "Sub" Then
.Range("J" & Rng.Row) = "=Sum(J" & BarisAwal & ":J" & Rng.Row - 1 & ")"
End If
Next
End With
With Application
.DisplayAlerts = True
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub
Bookmarks