Forum Discussion

jrwardesi's avatar
jrwardesi
Copper Contributor
May 10, 2021
Solved

Auto fill the next available Project # when a project is "won"

I have the attached Quote register for projects.  If a project is "won" in column G, I want the job # to be filled in with the next sequential # in column F.  This formula was suggested:  =IF(G2="Won...
  • HansVogelaar's avatar
    May 10, 2021

    jrwardesi 

    I think you'll need VBA for this.

    Rigt-click the sheet tab and select 'View Code' from the context menu.

    Copy the following code into the worksheet module:

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim rng As Range
        If Not Intersect(Range("G:G"), Target) Is Nothing Then
            Application.ScreenUpdating = False
            Application.EnableEvents = False
            For Each rng In Intersect(Range("G:G"), Target)
                If rng.Value = "Won" And rng.Offset(0, -1).Value = "" Then
                    rng.Offset(0, -1).Value = Application.Max(Range("F:F")) + 1
                End If
            Next rng
            Application.EnableEvents = True
            Application.ScreenUpdating = True
        End If
    End Sub

    Switch back to Excel.

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

    You'll have to allow macros when you open the workbook.

Resources