+ Reply to Thread
Results 1 to 5 of 5

Macro to activate window with variable name

  1. #1
    Registered User
    Join Date
    05-25-2011
    Location
    NY, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Macro to activate window with variable name

    Hi all,

    I know this can be done because I had help doing it before (over a year ago), but I am trying to find a code that will move macro between excel files with varying names. The problem is the last part of the file name changes everyday but the first part doesn't.

    So if the file name is: Hyper282740.xls I would like the macro to search for only "Hyper" and activate it.

    Also if the file is: DPS volume list 2011-05-25 is there a way to open today's file in the macro? Something like Today = "=today()" so DPS volume list "today".xls ?


    Many Thanks,
    Cyp

  2. #2
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro to activate window with variable name

    Re the second part of the question you can do something like this:

    Please Login or Register  to view this content.

    Assigning the workbook to a workbook object as above makes it easier to work with it later on in your code.

    As for the first part of your question do you mean you can multiple files of that name and the user should be allowed to pick the one they want or that it should just open a file beginning with "hyper' if it finds one in the specified directory?

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  3. #3
    Registered User
    Join Date
    05-25-2011
    Location
    NY, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Macro to activate window with variable name

    Hi Dom,

    Thanks for that code. I will open these spreadsheets manually, so they will already be open. I am needing a way for the macro to select them since the exact name will be different each time.

    Regards,
    Cyp

  4. #4
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Macro to activate window with variable name

    In my opinion it's better to get the code to prompt you for the file:

    Please Login or Register  to view this content.

    Dom

  5. #5
    Registered User
    Join Date
    05-25-2011
    Location
    NY, USA
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Macro to activate window with variable name

    Will do. Thanks for the help Dom.

+ 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