+ Reply to Thread
Results 1 to 7 of 7

Macro with button to number items within an invoice

  1. #1
    Registered User
    Join Date
    07-26-2010
    Location
    Pasadena, US
    MS-Off Ver
    Excel 2007
    Posts
    21

    Question Macro with button to number items within an invoice

    Hi everybody!

    Here's a business issue that I am having -

    My business needs to send a certain report to the tax authorities that shows all our purchases (inward data register).
    When our ERP system creates this report, we get a big excel file which has all the information pertaining to the purchase invoices that have been raised on our organisation.
    However, most invoices usually do have more than one line item in them BUT our software does not have the ability to tag these line items separately.
    Given we need to mention unique line items for each invoice in this report, we are currently doing so manually which needless to say is very time-consuming.
    I wanted to surface this on the forum and see if someone can suggest a macro code which would basically go through the entire column of "Invoice Number". Every time the code encounters an invoice number it should write "1" in front of it in the line items column. IF the same invoice number appears again, the code should write "2" in the line-item column. Similarly, if a third occurrence happens, write "3".
    It is very important to understand that every invoice number WILL have at least "1" in front of it in the line item column. IFF the same invoice number appears again, only then would it write "2".

    I am attaching a dummy file with the fields and some dummy values.

    If this could be done it would save my organisations hundreds of man hours every month.

    Any suggestions are very welcome and thanks in advance for the help!
    Attached Files Attached Files
    _________
    K.Thakur
    Sr. Fin. Analyst

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool At beginner level …


    Hi !

    As a very beginner formula yet does the job : in A2 cell just enter =COUNTIF(B$2:B2,B2) then copy down …
    Last edited by Marc L; 06-11-2018 at 04:17 AM.

  3. #3
    Registered User
    Join Date
    06-01-2017
    Location
    VietNam
    MS-Off Ver
    2016
    Posts
    8

    Re: Macro with button to number items within an invoice

    You refer
    PHP Code: 
    Sub Invoice_Number()     
        
    Dim sArr(), dArr(), As LongAs Long
    sArr 
    Range("B2"Range("B" Rows.Count).End(3)).Value
    ReDim dArr
    (1 To UBound(sArr1), 1 To 1)
    For 
    1 To UBound(sArr1)
        
    Application.CountIf(Range("B2:B" 1), Range("B" 1))
        
    dArr(I1) = Format(N"00000#")
    Next I
    Range
    ("A2"Range("A" Rows.Count).End(3)).ClearContents
    Range
    ("A2").Resize(1) = dArr
    End Sub 
    Last edited by PacificPR; 06-12-2018 at 09:28 AM.

  4. #4
    Registered User
    Join Date
    07-26-2010
    Location
    Pasadena, US
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: At beginner level …

    Thanks so much for the prompt reply.

    Will try and see if this suffices for the entire list of invoices.

  5. #5
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    So if really a code is needed, just directly applying the beginner formula :

    PHP Code: 
    Sub Demo1()
        
    With Sheet1.Range("A2"Sheet1.Cells(Rows.Count2).End(xlUp)(10))
            .
    NumberFormat "000000"
            
    .Formula "=COUNTIF(B$2:B2,B2)"
            
    .Formula = .Value
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !
    Last edited by Marc L; 06-11-2018 at 04:41 AM. Reason: formatting optimization …

  6. #6
    Registered User
    Join Date
    07-26-2010
    Location
    Pasadena, US
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Macro with button to number items within an invoice

    Thanks Pacific PR!!

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Macro with button to number items within an invoice


    Thanks for the rep' !

    Code in my previous post was edited …

+ 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. Choose Invoice Number from a userform combobox and copy data to invoice output
    By djemy1975* in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-07-2016, 06:02 AM
  2. Invoice Sales Tracker is messing up the invoice items
    By Kristina86 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-05-2015, 06:47 AM
  3. Macro for renaming PDF files. file name changinf from invoice number to PO number.
    By kkhoney in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-06-2014, 08:02 AM
  4. Counting the number of items on an invoice?
    By Ben1985 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-22-2013, 02:07 PM
  5. Replies: 4
    Last Post: 11-04-2012, 12:43 PM
  6. Excel 2007- creating a button that prints saves and increments invoice number
    By fellayaboy in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-22-2011, 09:35 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