How to customize how my invoices are saved

kelseyyy

New Member
Joined
Jun 30, 2023
Messages
3
Office Version
  1. 2019
Platform
  1. Windows
I'm currently taking my first steps in learning coding doing this. I want my invoices to have the customer name and then the invoice number. I have been successful in adding those things, however it is always saved like this, (as an example): Invoiceskelsey_12345
How do I make it so the invoices part is gone and I'm only left with kelsey_12345.

This is what I currently have

Sub NextInvoice()
Range("F5").Value = Range("F5").Value + 1
Range("B8").ClearContents
Range("A16:G30").ClearContents
End Sub

Sub SaveInvWithNewName()
Dim NewFN As Variant
' Copy Invoice to a new workbook
ActiveSheet.Copy
NewFN = "C:\Users\DELL\Documents\Invoices" & Range("B8").Value & "_" & Range("F5").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
ActiveWorkbook.Save
NextInvoice
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Leave the word "Invoices" out from your "NewFN" line
Code:
NewFN = "C:\Users\DELL\Documents\" & Range("B8").Value & "_" & Range("F5").Value & ".xlsx"
 
Upvote 0
Leave the word "Invoices" out from your "NewFN" line
Code:
NewFN = "C:\Users\DELL\Documents\" & Range("B8").Value & "_" & Range("F5").Value & ".xlsx"
Now it says documents before the name and invoice numbers?
 
Upvote 0
Good to see you've got it sorted. Kudos to you.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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