Forum Discussion

Dazzaman35901968's avatar
Dazzaman35901968
Copper Contributor
Jul 09, 2021
Solved

GENERATE A NEW JOB/PROJECT NUMBER WHEN YOU OPEN A SPREADSHEET

Hi Everyone,                       I am new to this forum so please be patient with me. I am currently been given the task to create a new work/time sheet for when doing field engineering work.  The...
  • HansVogelaar's avatar
    HansVogelaar
    Jul 09, 2021

    Dazzaman35901968 

    See if this does what you want:

    Press Alt+F11 to activate the Visual Basic Editor.

    Double-click ThisWorkbook in the Project Explorer pane on the left hand side.

    Copy the following code into the module:

    Private Sub Workbook_Open()
        With Worksheets(1).Range("B1")
            .Value = .Value + 1
        End With
    End Sub

    This version places the job number in cell B1 on the first sheet. You can change that in the code if you wish.

    Switch back to Excel.

    Save the workbook as a macro-enabled workbook (.xlsm).

    Make sure that you allow macros when you open it.

    See the attached sample workbook.

Resources