+ Reply to Thread
Results 1 to 6 of 6

Define a Workbook/WorkSheet Name by a String Value

  1. #1
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Define a Workbook/WorkSheet Name by a String Value

    Hi all the following code will put the worksheet name "SomeName" into
    A1 to A10 on Sheet2.

    Please Login or Register  to view this content.
    I want to do the reverse. I want to use a string to define a Workbook name to activate. The workbook to be activated will be a variant in such the name
    will always be what the value of the string.

    Here's my attempt in which I'm getting a mismatch error:

    Please Login or Register  to view this content.
    NE HLP is Greatly Appreciated.

    BDB
    Last edited by bdb1974; 10-20-2009 at 12:25 PM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Define a Workbook/WorkSheet Name by a String Value

    Hi.

    You just need to assign the string variable and then use:

    Please Login or Register  to view this content.
    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Define a Workbook/WorkSheet Name by a String Value

    Ok, I've tried setting it up the way Richard said.
    Tried running and got an object doesn't support this method error
    Why am I getting this error?
    Is something not setup right?

    Please Login or Register  to view this content.
    Ne help in fixing this is appreciated.

    Thanks,

    BDB
    Last edited by bdb1974; 10-20-2009 at 12:15 PM.

  4. #4
    Forum Contributor
    Join Date
    12-10-2008
    Location
    Austin
    Posts
    660

    Re: Define a Workbook/WorkSheet Name by a String Value

    Ok, I've found the error of my ways.

    I made a few changes along with placing the following
    Please Login or Register  to view this content.
    into my code exactly by the advised method.
    ....and Wallah! It works!!!

    Please Login or Register  to view this content.
    Thank YOU, Richard Buttrey! and to everyoone else who's helped me b4.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Define a Workbook/WorkSheet Name by a String Value

    Can you back up a step and explain what you're trying to do?
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Define a Workbook/WorkSheet Name by a String Value

    Hi,

    I'm not clear why you are using an IF statement before the workbooks open instruction. If the workbook is already open in memory you don't need to open it, just activate it, otherwise you need to open it with the instruction I mentioned.

    It also appears from the above that the variable StFileName 1 has not yet been assigned.

    Rgds

+ 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