+ Reply to Thread
Results 1 to 4 of 4

VBA - Defining Variable Named Open Workbooks

  1. #1
    Registered User
    Join Date
    10-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    VBA - Defining Variable Named Open Workbooks

    All,

    Thanks for the forum. I have found it very helpful, as I slowly learn some VBA. I want to know how to specifically define the names of open workbooks in VBA Code, from variable workbook names.

    For example I have 4 excel books, opened in no particular order: Workbook, Dog, Cat, Elephant.

    I want to define the workbooks Dog, Cat, Elephant, etc. so I can pull data from them and put it into the active workbook. The problem is that the names of the workbooks change everyday because the have the date in it.

    Again, for example. The Dog Workbook would be "Dog 10 - Oct - 2013", but it always starts with "Dog", so I was wondering if there is a way to define the open workbook something like

    Dog = workbooks("Dog*.XLS")

    but everything I try, it doesn't work.

    Thanks for any help.

    Jeremy

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VBA - Defining Variable Named Open Workbooks

    Hi, Jeremy,

    as long as it is one instance of Excel you may use either InStr for the name of Like

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Registered User
    Join Date
    10-17-2013
    Location
    Australia
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: VBA - Defining Variable Named Open Workbooks

    Many Thanks Holger! Works great.

    If InStr will come in very handy.

    Cheers,

    Jeremy

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: VBA - Defining Variable Named Open Workbooks

    Hi, Jeremy,

    thanks for the feedback. Do you mind marking the thread Solved via Thread Tools over the opening post?

    Holger

+ 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. Defining workbook variable not working with workbooks.open
    By hmbugg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-07-2013, 02:09 PM
  2. Simple Example to Explain Defining all Open Workbooks
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-21-2013, 02:35 PM
  3. using variable for open workbooks
    By venkat1926 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-18-2010, 01:22 PM
  4. Populate a Dropdown with names of open workbooks, when slected store as variable
    By andersonca in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2010, 12:11 PM
  5. Activate Variable Named Workbooks
    By HelpMe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-20-2005, 11:17 AM

Tags for this Thread

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