Ian Bertie
New Member
- Joined
- Jul 10, 2010
- Messages
- 21
Good afternoon Guru's
I am trying to dynamically sum a column (code below), however I am getting an error due to the cells having a formula (example: =IF(H47<>"",G47*H47,""))
Private Sub CommandButton1_Click()
lastrow = Worksheets("Invoice").Cells(Rows.Count, 9).End(xlUp).Row
Dim a As Integer
a = 0
For b = lastrow To 40 Step by - 1
a = a + Worksheets("Invoice").Cells(b, 9).Value
Next
Worksheets("invoice").Cells(lastrow + 2, 9).Value = a
End Sub
How can I create the total where the last cells is not blank
Thanks in advance
I am trying to dynamically sum a column (code below), however I am getting an error due to the cells having a formula (example: =IF(H47<>"",G47*H47,""))
Private Sub CommandButton1_Click()
lastrow = Worksheets("Invoice").Cells(Rows.Count, 9).End(xlUp).Row
Dim a As Integer
a = 0
For b = lastrow To 40 Step by - 1
a = a + Worksheets("Invoice").Cells(b, 9).Value
Next
Worksheets("invoice").Cells(lastrow + 2, 9).Value = a
End Sub
How can I create the total where the last cells is not blank
Thanks in advance