I have this question in another thread " What give Sum of user selected cellrange on sheet"
Here's my question again:-
What's the code for calculating a range of values in an excel column using VB.
I am trying to get the 'Sum' in excel to work.
here's a part of my code.
Dim CCExcelApp
Set ExcelApp = CreateObject("Excel.application"
With ExcelApp
.workbooks.open "filename.xls"
row = 7
For i = 1 To 20
.range("A" & CStr(row)).Select
.activecell.formular1c1 = i
.range("B" & CStr row)).Select
.activecell.formular1c1 = i
row = row + 1
Next
.range("A" & CStr(row)).Select
.selection.entirerow.Insert
.range("A" & CStr(row)).Select
.activecell.formular1c1 = "Total"
.range("B" & CStr(row)).Select
.activecell.formular1c1 = "=SUM(R[-9]B:R[-7]B)"
.range("A1".Select
.Visible = True
End With
Set ExcelApp = Nothing
I am gettin an runtime error and the code stops at the 'sum' line.
Any help is highly appreciated.
Here's my question again:-
What's the code for calculating a range of values in an excel column using VB.
I am trying to get the 'Sum' in excel to work.
here's a part of my code.
Dim CCExcelApp
Set ExcelApp = CreateObject("Excel.application"
With ExcelApp
.workbooks.open "filename.xls"
row = 7
For i = 1 To 20
.range("A" & CStr(row)).Select
.activecell.formular1c1 = i
.range("B" & CStr row)).Select
.activecell.formular1c1 = i
row = row + 1
Next
.range("A" & CStr(row)).Select
.selection.entirerow.Insert
.range("A" & CStr(row)).Select
.activecell.formular1c1 = "Total"
.range("B" & CStr(row)).Select
.activecell.formular1c1 = "=SUM(R[-9]B:R[-7]B)"
.range("A1".Select
.Visible = True
End With
Set ExcelApp = Nothing
I am gettin an runtime error and the code stops at the 'sum' line.
Any help is highly appreciated.