I want to code the click event of a command button to sum a range of currency formatted cells that I select in a worksheet, and then display the result in a label or text box with the same format. What do I need? Any help is greatly appreciated, thanks!!
I solved this myself, although the original idea has changed somewhat, it works for me. I used an Input box to insert a range of cells into my code. Now if I want to total a column of figures I select the cell where I want my total to be displayed and click the command button. The Input Box asks for the range I want to total, once I enter the range and click ok the total of the range of cells is displayed in the cell I selected. Works great!
Do u have the code for Summing a range of values in an excel column in 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
Do u have the code for Summing a range of values in an excel column in 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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.