formula or vba auto number based on two values

leap out

Active Member
Joined
Dec 4, 2020
Messages
271
Office Version
  1. 2016
  2. 2010
good day
I would auto number like my picture based on two value if in column a = " paid" & "unpaid " then insert in column b ,the column b contain value is 1 expresses the current month and if it enter month Feb then change to 2
Microsoft Excel .xlsx
AB
1UNPAID INVOICE NUMBER INV-1-1000
2UNPAID INVOICE NUMBER INV-1-1001
3PAIDVOUCHER NUMBER VOUCHER-1-C1000
4PAIDVOUCHER NUMBER VOUCHER-1-C1001
ورقة1
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Here is one method that works.

**** Before entering the formula you will need to go to Excel Options, then to the Formulas tab and check the 'Enable iterative calculation' box, if you do not do this then you will get a circular reference warning and the formula will fail. ****

Note that I have started in row 2, you can have headers in row 1 but not data.
Cell Formulas
RangeFormula
B2:B5B2=IF(A2="","",IF(AND(B2<>"",B2<>0,ISNA(MATCH(B2,B$1:B1,0))),B2,IF(A2="UNPAID","INVOICE NUMBER INV-"&MONTH(TODAY())&"-"&(COUNTIF(B$1:B1,"INVOICE NUMBER INV-"&MONTH(TODAY())&"-*")+1000),"VOUCHER NUMBER VOUCHER-"&MONTH(TODAY())&"-C"&(COUNTIF(B$1:B1,"VOUCHER NUMBER VOUCHER-"&MONTH(TODAY())&"-C*")+1000))))
 
Upvote 0
Solution
hi Jason
great formula , but I have a problem this is what I got not like your result , do you have any idea ?
 
Upvote 0
this is what I got not like your result
I can't see anything in your post showing what went wrong. Did you set the iterative calculation and move the data down to row 2 as per my suggestion?
 
Upvote 0
I did it and works but not show this
it supposes when write unpaid shows INVOICE NUMBER INV-1-1000
ورقة عمل Microsoft Excel جديد.xlsx
AB
2UNPAID VOUCHER NUMBER VOUCHER-1-C1000
3PAIDVOUCHER NUMBER VOUCHER-1-C1001
4PAIDVOUCHER NUMBER VOUCHER-1-C1002
sh
Cell Formulas
RangeFormula
B2:B4B2=IF(A2="","",IF(AND(B2<>"",B2<>0,ISNA(MATCH(B2,B$1:B1,0))),B2,IF(A2="UNPAID","INVOICE NUMBER INV-"&MONTH(TODAY())&"-"&(COUNTIF(B$1:B1,"INVOICE NUMBER INV-"&MONTH(TODAY())&"-*")+1000),"VOUCHER NUMBER VOUCHER-"&MONTH(TODAY())&"-C"&(COUNTIF(B$1:B1,"VOUCHER NUMBER VOUCHER-"&MONTH(TODAY())&"-C*")+1000))))
 
Upvote 0
hi Jason

I tried with a new workbook then it successes I no know if it is because when show this message "get a circular reference warning and the formula " before I select from option , any way many thanks for your assistance
 
Upvote 0
You have a space after UNPAID which is causing a mismatch, the formula looks for "UNPAID" not "UNPAID "

Select A2, then press the Delete key to clear the cell and retype UNPAID without a space.

Note that if you don't clear A2 first then the formula will not update. This is necessary to stop the dates from changing incorrectly.
 
Upvote 0
thanks for your notice and correcting me
the formula is a great
I appreciate your assistance
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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