+ Reply to Thread
Results 1 to 3 of 3

using a value from the sheet to the left of the active sheet

  1. #1
    Registered User
    Join Date
    03-20-2011
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    14

    using a value from the sheet to the left of the active sheet

    I have a sub that adds a new sheet then copies a template into the sheet and opens a user form that the user enters details of a sales order into. When the user submits the form the details are passed to the new sheet and then the sheet is renamed to whatever the order number is, which should be sequential 1,2,3 etc

    Is there a way for my user form to pick up the order number value from the previous sheet (remembering that I can't specify the name or number to refer to, only that it will be immediately to the left of the active sheet) and add 1 to that number and show that in the text box 'orderNo' , and then pass the new value to the new sheet on submit?

    If I could do this it would prevent my users from messing up the order number sequence.
    Last edited by vn900; 04-02-2011 at 09:55 AM.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: using a value from the sheet to the left of the active sheet

    Hi vn900,

    The answer is YES!!

    Sheets are indexed from left to right from 1 (the very left one) to the farthest on the right.
    You can do VBA code of.
    Activesheet.Index which will return the index number of the sheet you are looking at.
    This all means if you want to get somehing off the sheet to the immediate left you would use
    Please Login or Register  to view this content.
    So say you want to copy range A1 to E5 from the sheet to the left to the active sheet. Your code would look like

    Please Login or Register  to view this content.
    BTW - the last worksheet number is given by
    Please Login or Register  to view this content.

    hope all this brain drain helps.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    03-20-2011
    Location
    Brisbane
    MS-Off Ver
    Excel 2003
    Posts
    14

    Re: using a value from the sheet to the left of the active sheet

    That's great thanks a lot
    This was the sub I came up with to do what I want and it works great

    Please Login or Register  to view this content.
    I then locked the txtOrderNo box on the user form and bingo the next sequential number is placed into the new sheet and the user cannot mess the number up.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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