Forum Discussion
jrwardesi
May 10, 2021Copper Contributor
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...
- May 10, 2021
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 SubSwitch back to Excel.
Save the workbook as a macro-enabled workbook (*.xlsm).
You'll have to allow macros when you open the workbook.
HansVogelaar
May 10, 2021MVP
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.
jrwardesi
May 10, 2021Copper Contributor
Thank you so much Hans for the quick reply and the fix. Works perfectly!