+ Reply to Thread
Results 1 to 8 of 8

Auto-Number for PO spreadsheet

Hybrid View

  1. #1
    Registered User
    Join Date
    04-23-2015
    Location
    Swansea
    MS-Off Ver
    13
    Posts
    17

    Auto-Number for PO spreadsheet

    Hi All

    I have just set up a new Purchase Order spreadsheet for work, but am struggling with the auto-numbering.

    I want the PO numbers to been in the format of 2016001, 2016002, 2016003 (as shown), and to show the newest at the top/.

    I want to be able to press the 'new po number' button, and a new blank row appear (in Row 4).

    I've attached a quick screenshot for you.

    Would be grateful for any assistance.

    Thanks

    SarahPO.png

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,445

    Re: Auto-Number for PO spreadsheet

    Hi Sarah,

    Use your button to activate this code:

    Sub InsertNewPO()
        Rows("4:4").Insert Shift:=xlDown
        Range("5:5").Copy
        Range("4:4").PasteSpecial (xlPasteFormats)
        Range("A4").Value = Range("A5").Value + 1
        Application.CutCopyMode = False
        Range("A4").Select
    
    End Sub
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  3. #3
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Auto-Number for PO spreadsheet

    Try this:-
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address(0, 0) = "A4" Then
        Target.EntireRow.Insert
        Target.Offset(-1) = IIf(Target = "", 2016000, Target + 1)
    End If
    End Sub

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Auto-Number for PO spreadsheet

    Try this:-
    Right click sheet tab, Select "View Code", Vbwindow appears, Past code in window, Close Vb window
    Code runs when you click "A4"
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address(0, 0) = "A4" Then
        Target.EntireRow.Insert
        Target.Offset(-1) = IIf(Target = "", 2016000, Target + 1)
    End If
    End Sub

  5. #5
    Registered User
    Join Date
    04-23-2015
    Location
    Swansea
    MS-Off Ver
    13
    Posts
    17

    Re: Auto-Number for PO spreadsheet

    Hi All

    All works great, except that it copies the format of the row above, where the row colour is yellow :s

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Auto-Number for PO spreadsheet

    Perhaps this:-
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address(0, 0) = "A4" Then
        Target.EntireRow.Insert
        Target.Offset(-1).Interior.ColorIndex = xlNone
        Target.Offset(-1) = IIf(Target = "", 2016000, Target + 1)
    End If
    End Sub

  7. #7
    Registered User
    Join Date
    04-23-2015
    Location
    Swansea
    MS-Off Ver
    13
    Posts
    17

    Re: Auto-Number for PO spreadsheet

    Hi Mick

    Please see below, the A4 cell is blank, but the rest of the row is yellow.
    po2.png
    Last edited by sdjames1979; 07-20-2015 at 09:08 AM. Reason: P&C

  8. #8
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Auto-Number for PO spreadsheet

    Change line as below:-
    Target.Offset(-1).EntireRow.Interior.ColorIndex = xlNone

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Auto number items that are pasted into spreadsheet
    By bkg73123 in forum Excel General
    Replies: 3
    Last Post: 10-13-2014, 01:30 PM
  2. [SOLVED] formula to auto delete number in dropdown list when number appears in another cell #2
    By ddevins in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-28-2014, 08:31 AM
  3. [SOLVED] formula to auto delete number in dropdown list when number appears in another cell
    By ddevins in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 04-28-2014, 04:54 AM
  4. Replies: 7
    Last Post: 01-09-2014, 06:25 PM
  5. Auto Assign the next available number to a record in a spreadsheet.
    By tommytiger1972 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-07-2011, 01:44 AM
  6. Replies: 0
    Last Post: 05-23-2005, 10:06 AM
  7. assign auto number and auto date
    By Krit Kasem in forum Excel General
    Replies: 3
    Last Post: 01-14-2005, 12:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1