Save file name with consecutive number.

VBAPowerOhYeah

New Member
Joined
Sep 14, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I am not a VBA expert and would like some help.
I have a main sheet ("Sheet1") or I am making an invoice. And I have a button to save each invoice to another .xlsx file.

On "Sheet 2" I have a list of consecutive numbers.
10323434, 10323435, 10323436, 10323437….

I want the file name (the name of the invoice) to have the number "10323434" for the first invoice.
Then when I do the second invoice it will be "10323435", and so on.

Bills are not made every day and customers are different.
The dates too.

So, each invoice is different with consecutive numbers.

Example:
C: \ Invoice \

Invoice10323434-Clientabc-Date.xlsx
Invoice10323435-Clientuvwxyz-Date.xlsx
Invoice10323436-Clientefghijklm-Date.xlsx

...

Can we also check that the name of the invoice already exists?
Have a list of invoices?

Thank you in advance and good day
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
56,526
Office Version
  1. 365
Platform
  1. Windows
Welcome to the MrExcel board!

If you have a list of numbers in Sheet2 that you want to use consecutively, why not include in your existing macro to put, say, the word "Used" in the next column of Sheet 2 beside each number as you sue it. Then your code to create the next invoice just find the last "Used" in the column and gets the invoice number from the next row down?

If you need more detailed help, can you post your code that creates the invoice and also tell us just where in Sheet2 the invoice number list is?
 

Forum statistics

Threads
1,175,790
Messages
5,899,503
Members
434,778
Latest member
Alina N

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
Top