Automatically create job number based on prefix, year,month and entry number

TheShyButterfly

New Member
Joined
Nov 6, 2011
Messages
43
Hello and thank you for taking your time to read this post.

I have tried searching the internet and this forum but have not found anything that I have been able to modify to my needs.

So here is what I need help with.

I have a spreadsheet (excel 2010) with multiple columns - for example, Job#(A1), Event type(B1),KPI data (C1),SNP Order# (D1), ... etc ... there is so much information that a new workbook is derived from a template each month.

I need VBA code (or macro) in Column A2 which will increment with prefix 'SRC' then the 'year' 'month' and then increment by 1 so the job number would look like this:


SRC201309-0001 (SRC Year2013 month09 - JobNumber0001)

As the spreadsheet is saved as a template, it would be great if each time a workbook is created from this template, that it would automatically base the first job number on the year and month on that day and with first job number.

It would be appreciative if the code could include that if Column B has empty field that the Column A field remain blank until data is entered in Column b field (I'd imagine for example that the IF statement would kick in there .... eg. if(B2="","", and here is where the job number would be formulated ....


A
B
C
D
E
1
Job #
Event Type
KPI Data
SNP Order#
Weather
2
Earthquate
87
12112
Severe
3
Theft
93
12113
Overcast
4
5

<TBODY>
</TBODY>

So that the sheet will look like this ...

A
B
C
D
E
1
Job#
Event Type
KPI Data
SNP Order#
Weather
2
SRC201309-0001
Earthquate
87
12112
Severe
3
SCR201309-0002
Theft
93
12113
Overcast
4
5

<TBODY>
</TBODY>


I hope I have provided enough information and not confused you.



Thanking you in advance :)
Theshybutterfly
 
Thank you Jim, I didn't think of hiding the first row ... but that is an option if all else fails .....

Thank you for your contribution ... I appreciate the various perspectives, when one has a problem it is normal to just a have a 'tunnel' outlook and not able to 'think outside the square'.

Cheers,
Ingelise
 
Upvote 0

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Thank you all for your contributions ... it was strange because I hadn't caught up with all the posts til just now... but after I re-read the code that Vaskov17 wrote in post #7, I thought I'd change the 2 to a 1 ... and tested it out and was ecstatic to see that the job number remained the same :biggrin: But then I read Vaskov17's response in Post #17 .... I felt good that I thought the same thing.

A special thank you to you Vaskov17 ... thank you for persevering in your quest to resolving the problem, and in such a very timely manner.

I'm sure others will be able to use and adapt your code for their projects ;)

I can now 'give you the day off' ;)

Best wishes and gratitude,
TheShyButterfly
 
Upvote 0

Forum statistics

Threads
1,216,076
Messages
6,128,669
Members
449,463
Latest member
Jojomen56

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