I found a Code which creates a subtotal within a table. The Formula works fine, but I do not understand the Syntax of the sum Formula for the subtotal, which is:
"=SUM(R" & j & "C:R" & i & "C)"
What is meant with R
, C:R
and C
? Can anybody please translate how the respective Output, for example =SUMME(E$4:E$4)
corresponds to this formula?
This is the subtotal output Excel function:
The Code is as follows:
Dim iCol As Integer
Dim i As Integer 'Makro f?ngt ab diese Zeilenummer an
Dim j As Integer 'Makro geht mit diese Zeilenummer im Loop weiter
Worksheets("Italy").Activate
Application.ScreenUpdating = False
i = 4 'Makro f?ngt ab diese Zeilenummer ab
j = i
'Loops throught Col B Checking for match then when there is no match add Sum
Do While Range("A" & i) <> ""
If Range("A" & i) <> Range("A" & (i + 1)) Then
Rows(i + 1).Insert
Range("A" & (i + 1)) = "Subtotal " & Range("A" & i).Value
For iCol = 5 To 11 'Columns to Sum
Cells(i + 1, iCol).Formula = "=SUM(R" & j & "C:R" & i & "C)"
Next iCol
Range(Cells(i + 1, 1), Cells(i + 1, 10)).Font.Bold = True
Range(Cells(i + 1, 1), Cells(i + 1, 10)).Interior.Color = RGB(221, 237, 245)
i = i + 2
j = i
Else
i = i + 1
End If
Loop
Application.ScreenUpdating = True