+ Reply to Thread
Results 1 to 4 of 4

Automatically Incrementing Invoice Number Upon Opening File Macro not working

Hybrid View

  1. #1
    Registered User
    Join Date
    10-03-2012
    Location
    Schenectady, NY
    MS-Off Ver
    Office 365
    Posts
    10

    Question Automatically Incrementing Invoice Number Upon Opening File Macro not working

    I'll start by saying I don't have much experience with VBA and macros...

    I have been trying to use a macro to automatically increment invoice numbers upon opening a file, which I found at a website (but apparently I'm not allowed to link it due to this forum's rules)

    The Code is as follows:

    Private Sub Workbook_Open()
          Range(“D2”).Value = Range(“D2”).Value + 1
    End Sub
    Something is wrong though - when I open the file, the value in D2 does not automatically increment. When I run the routine via the Debugger, it increments, but not when I open the file. This may have something to do with the code being saved as a "module" rather than a Macro, but every time I try to save it as a Macro, I either get a compile error, or else it tells me, "This action will reset your project, proceed anyway?" (note, this happens because I am trying to delete "Sub Macro1()" at the beginning of the macro).

    How can I set up a proper macro that will increment the number in cell D2 every time I open the file?

    Any advice would be much appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Automatically Incrementing Invoice Number Upon Opening File Macro not working

    HI
    Try some thing like this
    Private Sub Workbook_Open()
        Sheets("sheet1").Range("D2").Value = Range("D2").Value + 1
    End Sub
    BTW this code should go to Thisworkbook Module
    Last edited by mohadin; 11-27-2019 at 05:20 AM.

  3. #3
    Registered User
    Join Date
    10-03-2012
    Location
    Schenectady, NY
    MS-Off Ver
    Office 365
    Posts
    10

    Re: Automatically Incrementing Invoice Number Upon Opening File Macro not working

    This works perfectly, thank you!

  4. #4
    Valued Forum Contributor
    Join Date
    06-27-2010
    Location
    sYRIA
    MS-Off Ver
    Excel 2013
    Posts
    669

    Re: Automatically Incrementing Invoice Number Upon Opening File Macro not working

    You are well come
    Thank you for the feedback
    Be Happy

+ 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. Macro to automatically generate invoice number
    By Tahya in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-13-2014, 04:39 PM
  2. 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
  3. Saving Invoice where next time I open file the Invoice Number increases by 1
    By domgee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-22-2013, 03:03 PM
  4. [SOLVED] run the macro automatically after opening the file
    By mukeshbaviskar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-17-2013, 11:44 AM
  5. Incrementing invoice number
    By txturbo in forum Excel General
    Replies: 2
    Last Post: 04-22-2007, 10:30 PM
  6. run a macro automatically upon opening an XLS file???
    By Ken Soenen in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-03-2005, 09:45 PM
  7. Replies: 1
    Last Post: 09-13-2005, 11:05 AM

Tags for this Thread

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