Results 1 to 2 of 2
  1. #1
    New Lounger
    Join Date
    Sep 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can I create a Template form in excel with serial numbers each time template opens?

    I was wondering if I could use excel to create a template for a form.
    I already figured out how to protect fields so they can't be changed, but I still need to generate a serial number each time a user opens the form.

    Can this be done in excel?

  2. #2
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,633
    Thanks
    115
    Thanked 646 Times in 590 Posts
    Rash,

    If you are referring to a unique identifier. place the following code in the ThisWorkbook module.

    Code:
    Private Sub Workbook_Open()
        Dim counter As Long, incrementer As Integer
        counter = 1001 'INITIAL COUNTER VALUE_CHANGE
        incrementer = 1 'INCREMENTING VALUE_CHANGE
        With Worksheets(1)
            If .Range("A1") = "" Then
                .Range("A1") = 1001
            Else
                .Range("A1") = .Range("A1") + incrementer
            End If
        End With
    End Sub
    Change the starting counter from 1001 to whatever value you like and the incrementer to any value you want the ID to increment by. Each time the workbook is opened, a unique value will be updated by one in cell A1 of Sheet 1.

    HTH,
    Maud
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •