reset counter change of year

orsm6

Active Member
Joined
Oct 3, 2012
Messages
496
Office Version
  1. 365
Platform
  1. Windows
Hi all - i am trying to improve a register that is used at work. in column A a macro inserts into the next blank cell a unique ID e.g. PCR21040.

PCR = hard coded - never changes
21 = current year - taken from last 2 digits of year in cell Q1
040 = is the last entry for that year (could be any amount... just depends)

how can i get the counter easily to reset to PCR22001 when the year changes? and obviously this happens each year that passes

TIA
 
you have "option explicit" on top of that module or somewhere a setting in the VBA-editor.
So, that's why you get that error.
Just add a0 and a1 in the line of "Dim ....
It's a kind of chicken/egg dilemma if you have to declare all variables.
Let's say i choose the chicken ...
VBA Code:
Option Explicit
Sub TS_newPCRID()
     Dim SPrefix, c, a0, a1
 
Upvote 0

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
you have "option explicit" on top of that module or somewhere a setting in the VBA-editor.
So, that's why you get that error.
Just add a0 and a1 in the line of "Dim ....
It's a kind of chicken/egg dilemma if you have to declare all variables.
Let's say i choose the chicken ...
VBA Code:
Option Explicit
Sub TS_newPCRID()
     Dim SPrefix, c, a0, a1
Perfect!! this works exactly as i need it to... thanks heaps :)
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,246
Members
449,075
Latest member
staticfluids

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