+ Reply to Thread
Results 1 to 8 of 8

VBA referencing worksheet by index, not by name.

  1. #1
    Registered User
    Join Date
    02-01-2010
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    42

    VBA referencing worksheet by index, not by name.

    Hello experts,

    The code I wrote copies data between two workbooks, each with worksheets numbered 1:32 with some additional worksheets as well.
    I want it to copy data from sheet "1" from Workbook-A into sheet "1" of workbook-B and then to repeat the process for all 32 workbooks.

    As the codes is now, it is referencing sheets by index - not by name. In workbook-B, sheet '1' is not the first tab. I need it to reference the name of the sheet (not the index) What am I doing wrong?


    Dim NextESheet As String


    Please Login or Register  to view this content.
    Last edited by adamNBU; 09-29-2013 at 06:18 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,409

    Re: VBA referencing worksheet by index, not by name.

    Maybe:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA referencing worksheet by index, not by name.

    Trevor, any reason not to condense it down to the single command:

    Please Login or Register  to view this content.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    02-01-2010
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: VBA referencing worksheet by index, not by name.

    Hello TMS,

    Actually, the code works well both ways. Thanks!!
    (my previous report here that there was a problem was not true). Thanks again!
    Last edited by adamNBU; 09-29-2013 at 07:16 PM.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,409

    Re: VBA referencing worksheet by index, not by name.

    Nope, none at all.

    I've just done a lot where I've wanted to copy and format and stuff and the With ... End With makes that neater.

    Just got carried away

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: VBA referencing worksheet by index, not by name.

    I've marked this thread as SOLVED for you.
    Next time, select Thread Tools from the links above to mark a thread as SOLVED. Thanks.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,409

    Re: VBA referencing worksheet by index, not by name.

    You're welcome.

  8. #8
    Registered User
    Join Date
    02-01-2010
    Location
    Sofia, Bulgaria
    MS-Off Ver
    Excel 2007
    Posts
    42

    Re: VBA referencing worksheet by index, not by name.

    I just signed back in to do exactly that.
    Solved, indeed.

+ 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. Index Referencing problem
    By orabbit in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-24-2013, 10:38 AM
  2. [SOLVED] referencing an index formula to another worksheet
    By Bonzopookie in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-04-2013, 05:42 PM
  3. Referencing a Workbook by Index
    By jamsta1972 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-02-2011, 06:47 PM
  4. Referencing current worksheet index number
    By pooley343 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-22-2011, 09:52 AM
  5. referencing arrays in index and match
    By inky in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-31-2007, 07:06 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