Giving a form a unique ID number

stimey89

New Member
Joined
Feb 19, 2010
Messages
10
I have created a form that when printed will be used as a rejection tag for isolating damaged or on-hold parts. Each tag that is printed must have a unique ID number. Is there a way to have excel automatically populate a field, giving each saved/printed tag a unique ID?

For example, I open the workbook and it automatically populates the ID field as #1, and then locks that field as #1 when I perform a saveas.

The next time I open the original workbook, it automatically populates the ID field as #2, and then locks that field as #2 when I perform a savas.

Thanks in advance for any help that can be offered.
 

baitmaster

Well-known Member
Joined
Mar 12, 2009
Messages
2,031
I take it you mean VBA form? And you already seem to have the right means for doing this on the spreadsheet itself, based on your question

simply save the latest form value into a named range, cell, or name within your spreadsheet, then retrieve it each time the form loads.
 

baitmaster

Well-known Member
Joined
Mar 12, 2009
Messages
2,031
sorry, I should always take two attempts to understand these questions... it always looks different second time I read it

You probably want to use the worksheet open and worksheet before close events in VBA
1) name a range in your workbook, "IDtracker"
2) Right click your sheettab and select "view code"
3) in the VBA screen, find ThisWorkbook on the left, and double click

Paste the code

Private Sub Workbook_Open()
Range("IDtracker").Value = Range("IDtracker").Value + 1
End Sub
 

stimey89

New Member
Joined
Feb 19, 2010
Messages
10
Thanks for your replies baitmaster. I'm sorry I didn't reply sooner, but I got pulled off of this project and never had a chance to try your tips on the form I was working on.

I appreciate you taking the time to respond and again, I'm sorry I didn't reply sooner.
 

Forum statistics

Threads
1,081,726
Messages
5,360,906
Members
400,602
Latest member
newaqua

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top