I'm trying to get TextBox1 in UserForm1 to auto populate with the next number in a sequence. The difficulty is that the number system is irregular. It follows this format: XXX-YYYY-ZZ , where XXX is a constant identifier of our organization, ZZ is the last two digits of the year, and YYYY is the sequential numbering from 0001 to 9999 for each item generated in that year (the zeros are important, as YYYY must be 4 digits).
I want to add to the UserForm macro, a way for it to find the largest YYYY for the current ZZ (year) in column A of ws1. Then add +1 to the YYYY portion, and suggest that as the next number to use in TextBox1 when UserForm1 is initiated.
For example, if column A has the following numbers:
555-0001-18
555-0002-18
555-0003-18
555-0001-19
555-0002-19
Then when UserForm1 is initialized, TextBox1 would already have the suggested value of 555-0003-19 ready.
Most likely column A will already be in numerical order, but ideally I'd like this macro to find the largest YYYY value for the current ZZ (year) without requiring the list to be in order. Not a dealbreaker if this is significantly more difficult. Thanks for the help!
I want to add to the UserForm macro, a way for it to find the largest YYYY for the current ZZ (year) in column A of ws1. Then add +1 to the YYYY portion, and suggest that as the next number to use in TextBox1 when UserForm1 is initiated.
For example, if column A has the following numbers:
555-0001-18
555-0002-18
555-0003-18
555-0001-19
555-0002-19
Then when UserForm1 is initialized, TextBox1 would already have the suggested value of 555-0003-19 ready.
Most likely column A will already be in numerical order, but ideally I'd like this macro to find the largest YYYY value for the current ZZ (year) without requiring the list to be in order. Not a dealbreaker if this is significantly more difficult. Thanks for the help!