+ Reply to Thread
Results 1 to 4 of 4

VBA code to retrieve worksheet names from an external workbook and update the current actv

  1. #1
    Registered User
    Join Date
    02-01-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    16

    VBA code to retrieve worksheet names from an external workbook and update the current actv

    I have an Excel workbook (BAMinit) code as attached
    It's purpose is to retrieve all of the worksheet names from another workbook (Bet Angel Multiple)
    then populate column A in BAMinit with these sheet names then go and initialise each of the retrieved sheets in Bet Angel Multiple
    Used to WORK LIKE A CHARM but has suddenly thrown an error when it gets to the THIRD sheet name when using Sheet.Name in the loop of all sheet names in Bet Angel Multiple

    Section of code (part of fully attached ) is:

    'Capture Sheet names and define formula to see if it should be initialised
    For xLoop = 1 To xCount
    xSheet = Sheets(xLoop).Name
    ThisWorkbook.Activate
    Range("A" & xLoop + 4) = xSheet
    xWbk.Activate
    Next xLoop

    Have explored all options but with no result

    Any help much appreciated

    Thanks

    BazzaBit
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA code to retrieve worksheet names from an external workbook and update the current

    I'd guess this might be an issue with which workbook is active, you might wish to try adding workbook and sheet references to your code.

    Maybe try something like:
    Please Login or Register  to view this content.
    in place of what you have in your post.

  3. #3
    Registered User
    Join Date
    02-01-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: VBA code to retrieve worksheet names from an external workbook and update the current

    Hi yudlugar,

    Thanks for your reply, it put me on the right track but even specically defining the path to the worksheets it didn't work

    However, I downloaded the original Bet Angel Multiple.xls from Bet Angel and it worked like a charm

    So my solution was to put my custom worksheets on the END, ie. after all the 3rd party sheets

    AND GUESS WHAT, it works like a charm so there must be some clever stuff that Bet Angel has done with their workbook

    But it now does exactly what I need so thanks for your assistance

    Cheers

    Bazzabit

  4. #4
    Registered User
    Join Date
    02-01-2013
    Location
    Australia
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: VBA code to retrieve worksheet names from an external workbook and update the current

    Issue now solved

+ 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. [SOLVED] Code that finds and deletes names from current sheet to all worksheets in workbook
    By grazian2 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-01-2013, 11:51 AM
  2. Replies: 2
    Last Post: 07-31-2013, 03:21 PM
  3. [SOLVED] Copying data from external workbook into current workbook based on cell value
    By Brontosaurus in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-07-2012, 11:17 AM
  4. How do I retrieve the current workbook link in vba?
    By whylite in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-17-2006, 01:15 AM
  5. Replies: 3
    Last Post: 06-10-2005, 04:05 PM

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