Generate the next number on these sequence

mark692

Active Member
Joined
Feb 27, 2015
Messages
321
Office Version
  1. 2016
Platform
  1. Windows
hi guys is there a formula that will generate the next number on these sequence,
the sequence will be like this
ex.
40120-1
40120-2
40120-3
40120-4
and so on and so on

40120 is tha date today
the number after 40120 is the sequence i want to change every time i add another transaction
 
there are times that i need to put the same transaction number in the column
Hmm, no mention of that before in either description or examples. ;)

Here are a few other options to consider, including a user-defined function since you said vba was acceptable.

VBA Code:
Function NextNum(rTansactions As Range) As String
  Dim vSplit As Variant
  Dim sPrefix As String
  
  sPrefix = Format(Date, "mmddyy-")
  NextNum = sPrefix & 1
  On Error Resume Next
  NextNum = sPrefix & Split(rTansactions.Find(What:=sPrefix, LookAt:=xlPart, SearchDirection:=xlPrevious), "-")(1) + 1
End Function


mark692 2020-04-02 1.xlsm
BCDEF
1
2Next Transaction CodeTransactionCash
3040220-4040220-1
4040220-4040220-2
5040220-4040220-2
6040220-3
7
8
9
10
11
12
13
Sheet1
Cell Formulas
RangeFormula
B3B3=TEXT(TODAY(),"mmddyy-")&IF(COUNTIF(Table4[Transaction],TEXT(TODAY(),"mmddyy")&"*"),MID(LOOKUP("z",Table4[Transaction]),8,99)+1,1)
B4B4=TEXT(TODAY(),"mmddyy-")&IF(COUNTIF(E3:E1000,TEXT(TODAY(),"mmddyy")&"*"),MID(LOOKUP("z",E:E),8,99)+1,1)
B5B5=NextNum(Table4[Transaction])
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Hmm, no mention of that before in either description or examples. ;)

Here are a few other options to consider, including a user-defined function since you said vba was acceptable.

VBA Code:
Function NextNum(rTansactions As Range) As String
  Dim vSplit As Variant
  Dim sPrefix As String
 
  sPrefix = Format(Date, "mmddyy-")
  NextNum = sPrefix & 1
  On Error Resume Next
  NextNum = sPrefix & Split(rTansactions.Find(What:=sPrefix, LookAt:=xlPart, SearchDirection:=xlPrevious), "-")(1) + 1
End Function


mark692 2020-04-02 1.xlsm
BCDEF
1
2Next Transaction CodeTransactionCash
3040220-4040220-1
4040220-4040220-2
5040220-4040220-2
6040220-3
7
8
9
10
11
12
13
Sheet1
Cell Formulas
RangeFormula
B3B3=TEXT(TODAY(),"mmddyy-")&IF(COUNTIF(Table4[Transaction],TEXT(TODAY(),"mmddyy")&"*"),MID(LOOKUP("z",Table4[Transaction]),8,99)+1,1)
B4B4=TEXT(TODAY(),"mmddyy-")&IF(COUNTIF(E3:E1000,TEXT(TODAY(),"mmddyy")&"*"),MID(LOOKUP("z",E:E),8,99)+1,1)
B5B5=NextNum(Table4[Transaction])


i tried it and i thinks this is better it also give transaction number even if my column is empty! thank you!
 
Upvote 0

Forum statistics

Threads
1,215,250
Messages
6,123,887
Members
449,130
Latest member
lolasmith

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