dmkennard2
Technical User
Hi,
I am using code to extract data from Access into a spreadsheet.
I am having problems inserting formula at the end of certain data columns that totals the column above. The first row will always be row 8 but the last row will always change.
Am i missing something in my formula code below as it fails each time i run it.
Thanks in advance.
Dazz
I am using code to extract data from Access into a spreadsheet.
I am having problems inserting formula at the end of certain data columns that totals the column above. The first row will always be row 8 but the last row will always change.
Am i missing something in my formula code below as it fails each time i run it.
Code:
lngLastRow = xlSheet.Range("A65536").End(xlUp).Row
lngLastColumn = xlSheet.Range("Z7").End(xlToLeft).Column
Set xlRange = xlSheet.Range(Cells(lngLastRow + 1, lngLastColumn - 7), xlSheet.Cells(lngLastRow + 1, lngLastColumn - 7))
' Insert formulas
With xlRange
.Value = "Results"
End With
Set xlRange = xlSheet.Range(Cells(lngLastRow + 1, lngLastColumn - 6), xlSheet.Cells(lngLastRow + 1, lngLastColumn - 6))
With xlRange
.FormulaR1C1 = "=SUM(R[" & 8 - lngLastRow & "]C:R[" & lngLastColumn & "]C)"
End With
Thanks in advance.
Dazz