SOLVED

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

%3CLINGO-SUB%20id%3D%22lingo-sub-2340853%22%20slang%3D%22en-US%22%3EAuto%20fill%20the%20next%20available%20Project%20%23%20when%20a%20project%20is%20%22won%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2340853%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20the%20attached%20Quote%20register%20for%20projects.%26nbsp%3B%20If%20a%20project%20is%20%22won%22%20in%20column%20G%2C%20I%20want%20the%20job%20%23%20to%20be%20filled%20in%20with%20the%20next%20sequential%20%23%20in%20column%20F.%26nbsp%3B%20This%20formula%20was%20suggested%3A%26nbsp%3B%26nbsp%3B%3DIF(G2%3D%22Won%22%2CSUM(MAX(235%2CF%241%3AF1)%2C1)%2C%22%22)%20but%20it%20only%20works%20if%20the%20projects%20are%20won%20in%20row%20order%20from%20top%20to%20bottom.%26nbsp%3B%20Otherwise%2C%20project%20%23's%20are%20renumbered%20when%20the%20project%20above%20it%20is%20won.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2340853%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2340991%22%20slang%3D%22en-US%22%3ERe%3A%20Auto%20fill%20the%20next%20available%20Project%20%23%20when%20a%20project%20is%20%22won%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2340991%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1049814%22%20target%3D%22_blank%22%3E%40jrwardesi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESome%20questions%20for%20you.%3C%2FP%3E%3COL%3E%3CLI%3EWhat%20is%20the%20volume%20of%20jobs%20bid%20and%20won%20on%20any%20given%20day%3F%3C%2FLI%3E%3CLI%3EDo%20the%20Job%20numbers%20have%20to%20be%20sequential%3F%20Aren't%20they%20basically%20identifiers%2C%20codes%20that%20can%20be%20used%20in%20other%20tables%20to%20refer%20to%20the%20job%20by%20something%20other%20than%20name%3F%3C%2FLI%3E%3C%2FOL%3E%3CP%3EThe%20reason%20I%20ask%3A%20depending%20on%20volume%2C%20you%20could%20do%20something%20else%20altogether.%20For%20example%2C%3C%2FP%3E%3CUL%3E%3CLI%3EMake%20the%20job%20number%20the%20underlying%20date%20number%20associated%20with%20the%20date%20on%20the%20day%20the%20contract%20is%20%22Won.%22%20For%20example%20today's%20date%20is%205%2F10%2F21%3B%20Excel's%20number%20for%20that%20date%20is%2044326.%20So%2044326%20could%20be%20the%20Job%20%23%20for%20any%20contract%20won%20on%20this%20date.%3C%2FLI%3E%3CLI%3EIf%20there%20are%20many%20jobs%20won%20on%20any%20given%20day%2C%20you%20could%20get%20that%20down%20to%20the%20decimal%20based%20on%20date%20and%20time.....%3C%2FLI%3E%3CLI%3EAnd%2C%20of%20course%2C%20if%20the%20volume%20is%20small%20enough%2C%20easily%20managed%2C%20there's%20no%20actual%20need%20to%20automate%20the%20assigning%20of%20a%20number.%20I%20know%20it's%20fun%20to%20write%20a%20formula--I've%20been%20bitten%20by%20the%20bug%20too--but%20there%20are%20times%20when%20simpler%20is%20better%20even%20if%20it's%20%22manual.%22%3C%2FLI%3E%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2340996%22%20slang%3D%22en-US%22%3ERe%3A%20Auto%20fill%20the%20next%20available%20Project%20%23%20when%20a%20project%20is%20%22won%22%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2340996%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1049814%22%20target%3D%22_blank%22%3E%40jrwardesi%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20think%20you'll%20need%20VBA%20for%20this.%3C%2FP%3E%0A%3CP%3ERigt-click%20the%20sheet%20tab%20and%20select%20'View%20Code'%20from%20the%20context%20menu.%3C%2FP%3E%0A%3CP%3ECopy%20the%20following%20code%20into%20the%20worksheet%20module%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3EPrivate%20Sub%20Worksheet_Change(ByVal%20Target%20As%20Range)%0A%20%20%20%20Dim%20rng%20As%20Range%0A%20%20%20%20If%20Not%20Intersect(Range(%22G%3AG%22)%2C%20Target)%20Is%20Nothing%20Then%0A%20%20%20%20%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20%20%20%20%20Application.EnableEvents%20%3D%20False%0A%20%20%20%20%20%20%20%20For%20Each%20rng%20In%20Intersect(Range(%22G%3AG%22)%2C%20Target)%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20rng.Value%20%3D%20%22Won%22%20And%20rng.Offset(0%2C%20-1).Value%20%3D%20%22%22%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20rng.Offset(0%2C%20-1).Value%20%3D%20Application.Max(Range(%22F%3AF%22))%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20Next%20rng%0A%20%20%20%20%20%20%20%20Application.EnableEvents%20%3D%20True%0A%20%20%20%20%20%20%20%20Application.ScreenUpdating%20%3D%20True%0A%20%20%20%20End%20If%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3ESwitch%20back%20to%20Excel.%3C%2FP%3E%0A%3CP%3ESave%20the%20workbook%20as%20a%20macro-enabled%20workbook%20(*.xlsm).%3C%2FP%3E%0A%3CP%3EYou'll%20have%20to%20allow%20macros%20when%20you%20open%20the%20workbook.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

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",SUM(MAX(235,F$1:F1),1),"") but it only works if the projects are won in row order from top to bottom.  Otherwise, project #'s are renumbered when the project above it is won.  

3 Replies

@jrwardesi 

Some questions for you.

  1. What is the volume of jobs bid and won on any given day?
  2. Do the Job numbers have to be sequential? Aren't they basically identifiers, codes that can be used in other tables to refer to the job by something other than name?

The reason I ask: depending on volume, you could do something else altogether. For example,

  • Make the job number the underlying date number associated with the date on the day the contract is "Won." For example today's date is 5/10/21; Excel's number for that date is 44326. So 44326 could be the Job # for any contract won on this date.
  • If there are many jobs won on any given day, you could get that down to the decimal based on date and time.....
  • And, of course, if the volume is small enough, easily managed, there's no actual need to automate the assigning of a number. I know it's fun to write a formula--I've been bitten by the bug too--but there are times when simpler is better even if it's "manual."
best response confirmed by allyreckerman (Microsoft)
Solution

@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.

Thank you so much Hans for the quick reply and the fix. Works perfectly!