MrExcel podcast 1505 / 1808

Evergen

New Member
Joined
Mar 20, 2016
Messages
2
Hi, am struggling with Macros from podcast 1505 and 1808. Here, a macro is written to do the following:

1. generate the next invoice number
2. clear certain fields ready for next invoice data to be filled in
3. save workbook with a unique name to specific folder on C drive
4. carry key data from each invoice through to invoice register.

Points 1, 2, 4 work fine but point 3 I am struggling with. It doesn't save with a unique number so when I draft a new invoice I am required to save over the previously saved worksheet. Here is the code as I have it, I really hope someone can point me the right direction :

Sub PostToRegister()
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Set WS1 = Worksheets("Invoice")
Set WS2 = Worksheets("Register")

' Figure out which row is the next row
NextRow = WS2.Cells(Rows.Count, 1).End(xlUp).Row + 1


' Write the important values to register
WS2.Cells(NextRow, 1).Resize(1, 8).Value = Array(WS1.Range("K16"), WS1.Range("H16"), WS1.Range("B16"), WS1.Range("B22"), WS1.Range("N16"), WS1.Range("O48"), WS1.Range("O52"), WS1.Range("V25"))




End Sub
Sub NextInvoice()
Range("K16").Value = Range("K16").Value + 1
Range("V3:W21").ClearContents
End Sub


Sub SaveWithNewName()
Dim NewFN As Variant
PostToRegister
' Copy Invoice to a new workbook
ActiveSheet.Copy
NewFN = "C:\Users\User\Dropbox\Evergen - Invoices\Sales Invoices" & Range("K16").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Forum statistics

Threads
1,217,356
Messages
6,136,079
Members
449,988
Latest member
Mabbas

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top