+ Reply to Thread
Results 1 to 1 of 1

VBA to add a previous worksheet reference/value

  1. #1
    Registered User
    Join Date
    08-12-2021
    Location
    UK
    MS-Off Ver
    MS 2010
    Posts
    6

    VBA to add a previous worksheet reference/value

    I have created a system auto-add a new invoice to worksheet. I am trying to make this as user friendly as possible and have used the 'no duplicates' code in several of my commands.
    But then I thought it would be much easier to just have the new worksheet created, auto-generate an invoice number. Because although this command gives 2 warnings, it still saves the worksheet initially as the first invoice ref typed in "C10". If the user does not resave the invoice after re-input it will save invoice ref as duplicate. I have tried several avenues, and cannot get this to work.
    I have been at this all night, and can not come up with a way to add the previous sheet cell ref, (which will be saved by user) and add 1 to create the new cell ref. My last ref is TT913 (so previous sheet to NewSheet created). This shows the last of my roads to research.
    Please can anyone help?

    The code I have so far is:


    Worksheets("Activesheet").Copy before:=Sheets("Master")
    ActiveSheet.Name = "NewSheet"
    Dim Ws As Worksheet

    Set Ws = Worksheets("NewSheet")
    Worksheets("NewSheet").Range("e10") = Now
    Ws.Unprotect Password:="password"
    ActiveSheet.CommandButton1.BackColor = &H8080FF

    Function PrevSheet(RCell As Range)
    Dim xIndex As Long
    Application.Volatile
    xIndex = [c10]Worksheet.Index
    If xIndex > 1 Then _
    PrevSheet = Worksheets(xIndex - 1).Range(RCell.Address)
    End Function


    End Sub

    I have tried several times to upload the file, but even though i have removed all personalised worksheets/ data and vba it is still telling me its 'too large'
    Last edited by Rileytommy85; 08-12-2021 at 02:26 AM.

+ 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. Reference Previous Worksheet Name
    By bmhalula in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-16-2012, 02:42 PM
  2. [SOLVED] How to reference to the previous worksheet regardless of title?
    By SeabeePlumber in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  3. [SOLVED] How to reference to the previous worksheet regardless of title?
    By SeabeePlumber in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  4. [SOLVED] How to reference to the previous worksheet regardless of title?
    By SeabeePlumber in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 04:05 AM
  5. [SOLVED] How to reference to the previous worksheet regardless of title?
    By SeabeePlumber in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  6. [SOLVED] How to reference to the previous worksheet regardless of title?
    By SeabeePlumber in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 11:05 PM
  7. [SOLVED] How to reference to the previous worksheet regardless of title?
    By SeabeePlumber in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  8. [SOLVED] How to reference to the previous worksheet regardless of title?
    By SeabeePlumber in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-15-2005, 07: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