Stephenosn
Board Regular
- Joined
- Jun 2, 2015
- Messages
- 52
Hello all,
I'm having trouble with a small micro running much slower than I believe it should. Please see the code bellow.
I have walked through the code and it appears the problem is with the following procedure.
Please let me know if there is something I'm missing here that would speed this macro up or a better way to write the code.
Thank you for having a look,
John
I'm having trouble with a small micro running much slower than I believe it should. Please see the code bellow.
Code:
Sub NBill_Click()
Dim NBill As Integer
NBill = MsgBox("This action will update the previous percent complete and the total billed to date?", _
vbOKCancel, "NEW BILLING PERIOD?")
If NBill = vbCancel Then
Exit Sub
End If
'Add Amount to bill this period to total amount billed to-date
Dim ABill As Object
For Each ABill In Range("J5:J60")
ABill.Value = ABill.Offset(0, 0).Value _
+ ABill.Offset(0, -1).Value
Next
'Replace previous percent complete with percent completed to-Date
Dim rng As Range
Set rng = Worksheets("SOV").Range("H5:H60")
Worksheets("SOV").Range("F5").Resize _
(rng.Rows.Count, rng.Columns.Count).Cells.Value = rng.Cells.Value
End Sub
I have walked through the code and it appears the problem is with the following procedure.
Code:
'Add Amount to bill this period to total amount billed to-date Dim ABill As Object
For Each ABill In Range("J5:J60")
ABill.Value = ABill.Offset(0, 0).Value _
+ ABill.Offset(0, -1).Value
Next
Please let me know if there is something I'm missing here that would speed this macro up or a better way to write the code.
Thank you for having a look,
John