+ Reply to Thread
Results 1 to 3 of 3

Referencing a workbook

  1. #1
    Registered User
    Join Date
    04-20-2016
    Location
    Henley, England
    MS-Off Ver
    MS Office Pro Plus 2013
    Posts
    7

    Referencing a workbook

    Hello,

    I'm having some trouble referencing a workbook. My current macro is as follows:

    Please Login or Register  to view this content.
    I want to reference the JRH Data Input Analysis sheet as users may rename the file.

    I tried using

    Set wbThis = Activeworkbook

    and then replacing Workbooks("JRH Data Input Analysis.xlsm").Activate with Workbooks(wbThis).Activate

    but that didn't seem to work. Any suggestions?

    PS. I know my code isn't great but its my first time using vba

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Referencing a workbook

    If you really need to activate the workbook referred to by wbThis drop the Workbooks bit.
    Please Login or Register  to view this content.
    PS If wbThis actually refers to the workbook the code is in you can use ThisWorkbook to refer to it.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    04-20-2016
    Location
    Henley, England
    MS-Off Ver
    MS Office Pro Plus 2013
    Posts
    7

    Re: Referencing a workbook

    Thanks! If you can see any issues with my code I would also appreciate any pointers to tidy up for future reference!

+ 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. Moving worksheet with named ranges to new workbook without referencing old workbook
    By madcaplaughs79 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-28-2014, 07:54 PM
  2. [SOLVED] Index Match Function Within One Workbook Referencing Cells in Another workbook error
    By Hackboss007 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 02-18-2014, 12:06 PM
  3. [SOLVED] Trouble copying data from closed workbook into active workbook, referencing help
    By lepperga in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2013, 01:48 PM
  4. Replies: 5
    Last Post: 03-21-2013, 07:34 AM
  5. Replies: 2
    Last Post: 04-24-2009, 03:45 PM
  6. referencing from different workbook
    By haitham1984 in forum Excel General
    Replies: 3
    Last Post: 01-22-2009, 10:04 AM
  7. referencing workbook from cells in another workbook
    By jlejehan in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-03-2006, 10:24 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