kevindorward_dfsdanf
New Member
- Joined
- Nov 5, 2019
- Messages
- 9
So I have a userform with comboboxes feeding on to a label to create a document name. I need to tag sequential numbering to the end based on all the criteria that makes up the document name e.g the number following should only ever increase if document name preceeding it is identical.
Have done this using formulas but having trouble translating that to the userform.
I want to be able to look at the document name that comboboxes have produced without the number added on, see if any cells match have that document name as the start with a number after it in the sheet, find the max value of that number and +1
My thoughts about how I might achieve it:
Define start number as 000001
Define Dummy string
Find the document name the comboboxes produce up to last character and define that as a string i.e. Dname
Define last row and look at the string before the numbers
For x=1 to last row
Doc number
If leftmost 25 characters = dname (I. e. It exists in the range) then extract max rightmost 6 numbers and define that as last used number else number is 000001
New number = last number +1
Document name = Dname & "-" & new number
The document name is not a set length though, sometimes I can be 22,24,26 characters and so looking at the leftmost characters I don't think will work.
Have done this using formulas but having trouble translating that to the userform.
I want to be able to look at the document name that comboboxes have produced without the number added on, see if any cells match have that document name as the start with a number after it in the sheet, find the max value of that number and +1
My thoughts about how I might achieve it:
Define start number as 000001
Define Dummy string
Find the document name the comboboxes produce up to last character and define that as a string i.e. Dname
Define last row and look at the string before the numbers
For x=1 to last row
Doc number
If leftmost 25 characters = dname (I. e. It exists in the range) then extract max rightmost 6 numbers and define that as last used number else number is 000001
New number = last number +1
Document name = Dname & "-" & new number
The document name is not a set length though, sometimes I can be 22,24,26 characters and so looking at the leftmost characters I don't think will work.