I have a billing estimate workbook that we use for our projects. I'd like to be able to use VBA to copy the old worksheet to a new worksheet and update the numbers. We have Columns H/I that are the Previous billing quantity/Amount that has to be copied from the previous worksheet. We have columns J/K that are this application totals, Columns L/M are completed to date numbers which always have to be updated and then finally we have a Balance to finish columns N/O. The two cells are Quantity/Amount for each of the Billings. What I would like to accomplish, is being able to hit a macro button and the newest sheet in the workbook is copied, renamed to Estimate (X), and all the info from columns J/K are copied and pasted into H/I. With each new worksheet, I'd like to have columns L/M & N/O updated with each new sheet. I've attached a sample. I'm struggling how to keep a running total on the completed to date columns (L/M) and the Balance to Finish Columns (N/O)
Here is the code that I've pulled that allows me to copy a new worksheet and update the links, but it only works once, and then it zeros columns out.
Here is a sample of the billing.
Here is the code that I've pulled that allows me to copy a new worksheet and update the links, but it only works once, and then it zeros columns out.
VBA Code:
Sub NewEstimate()
Dim h As Long, i As Long, u As Long
Dim sc As Long, sc1 As Long, sc2 As Long
Dim endrow As Long
endrow = Sheets(1).Cells(Rows.Count, 1).End(3).Row
h = 15
sc = Sheets.Count
h = h + 15
Sheets(1).Copy After:=Sheets(Sheets.Count)
Sheets(Sheets.Count).DisplayRightToLeft = False
sc2 = Sheets.Count
If sc2 > sc1 Then
u = h - 13
Sheets(Sheets.Count).Name = "ESTIMATE" + Str(sc2 - 1)
End If
For i = 2 To Sheets.Count
Sheets(i).Range("z2") = i - 1
Sheets(i).Range("ab2") = Sheets.Count - 1
Next
Sheets(Sheets.Count - 1).Range("I11:I126").Copy
Sheets(Sheets.Count).Range("G11:G126").PasteSpecial xlPasteAll
Sheets(Sheets.Count).Range("I11:I126").ClearContents
End Sub
Here is a sample of the billing.
Dropbox - File Deleted - Simplify your life
www.dropbox.com