Next Invoice Number Save as .xlsm

erware

New Member
Joined
Nov 20, 2019
Messages
9
I have a Macro enable template with the below Macro that you wrote. It works but I would like for it to save the new file as a macro enable file "xlsm" instead of an excel .xlsx file. Is this possible?

Sub SaveAndNewInvoiceWithNewName()
Dim NewFN As Variant
' Copy Invoice to a New Workbook
ActiveSheet.Copy
NewFN = "C:\Users\Eddie\Documents\IDrive-Sync\Dropbox\LB Historical Society\Treasurer's Programs\Invoicing\Invoices\" & Range("F10") & Range("G10") & Range("H10") & Range("C22") & Range(" D17 ").Value
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
Range("G10").Value = Range("G10").Value + 1
Range("C25:D42").ClearContents

End Sub
 
I put all of the Data on the invoice sheet and created new drop down linked to the new location, hide the columns and it works as needed. I deleted the other 3 sheets.
I am glad I found your site, you have a wealth of useful information.
I signed up for your E-junkie Affiliate Programs and will be adding the HTML Button Code to 4 sites.
Thanks for all you do.
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I found a way to may it work. I put all of the data on the Invoice page and created new Data Validation criteria drop down lists and changed the VLOOKUP to the new location. I hide the columns to the sheet so it not look so cluttered.

I signed up for you Affiliate Program “Holy Marco Books” and will be adding the HTML Button Code to 5 website.

One minor problem is that the Invoice number is advancing by 2 not 1, (I can live with this but would rather it advanced by 1). This is the code:
Sub SaveAndNewInvoiceWithNewName()
Dim NewFN As Variant
' Copy Invoice to a New Workbook
ActiveSheet.Copy
NewFN = "C:\Users\Eddie\Documents\IDrive-Sync\Dropbox\LB Historical Society\Treasurer's Programs\Invoicing\Invoices\" & Range("F10") & Range("G10") & Range("H10") & Range("C22") & Range(" D17 ").Value
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbookMacroEnabled
ActiveWorkbook.Close
NextInvoice
Range("G10").Value = Range("G10").Value + 1
Range("C25:D42").ClearContents
End Sub
 
Upvote 0
I am guessing that "NextInvoice" is the code that is determing the next invoice number?
We would probably need to see the code behind that.
 
Upvote 0
Corrected the problem.
I removed Nextinvoice from the macro and now will it advance by 1 number. It was running the macro NextInvoice and "Range("G10").Value = Range("G10").Value + 1" which made it advance by 2.

Thanks
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,666
Members
449,091
Latest member
peppernaut

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