PDA

View Full Version : sum then devide by a hundred



slamet Harto
04-29-2009, 10:06 PM
guys,

can you advise why the following formula doesn't work.
I want to sum (let say H10 to H15) then devide by 100.

Thanks for support


Public Sub SumACycle()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim lastrow As Long

With ActiveSheet

lastrow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).row
.Cells(lastrow + 1, "A").Value = "TOTAL"
.Cells(lastrow + 1, "H").Formula = "=SUM(H10:H" & lastrow & ")" /100
.Cells(lastrow + 1, "I").Formula = "=SUM(I10:I" & lastrow & ")" /100

End With
End sub

xluser2007
04-29-2009, 11:14 PM
Slamet,

Does this work:

Public Sub SumACycle()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim lastrow As Long

With ActiveSheet

lastrow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).row
.Cells(lastrow + 1, "A").Value = "TOTAL"
.Cells(lastrow + 1, "H").Formula = "=SUM(H10:H" & lastrow & ")/100"
.Cells(lastrow + 1, "I").Formula = "=SUM(I10:I" & lastrow & ")/100"

End With
End sub
That is make the /100 as part fo the formula String (i.e.Text) not a numerical division operation as you would like excel to do in the formula in the actual cells.

HTH

slamet Harto
04-30-2009, 12:06 AM
Slamet,

Does this work:



yes it does. Thanks for quick response.

Thanks & rgds