Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Auto numbering in Excel based on cell criteria.

Status
Not open for further replies.

jock95

Programmer
Feb 19, 2005
7
0
0
US
I am looking to have a cell that contains a Number, like a Purchase Order Number. When the excel worksheet is opened and a particular cell is changed, then the number will advance 1 spot. Creating a new PO.

Any suggestions?
 
Jock95,

I do not know what you are looking for exactly. But this code:
Code:
   ActiveCell = Range("A1").Value + 1

Adds a value of 1 to the value in cell A1 and places this in the current cell. You can of course replace the "A1" with a variable.

Hope that is what you are looking for.

W.
 


Assuming that your invoice numbers will be in column A
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.EnableEvents = False
    With Target
        If .Count = 1 Then
            If Cells(.Row, 1).Value = 0 Then
                Cells(.Row, 1).Value = Application.Max(Range("A:A")) + 1
            End If
        End If
    End With
    Application.EnableEvents = True
End Sub

Skip,
[sub]
[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top