+ Reply to Thread
Results 1 to 6 of 6

Referencing an Opened Workbook (with variable in file name)

  1. #1
    Registered User
    Join Date
    12-15-2015
    Location
    Seattle
    MS-Off Ver
    Windows 10
    Posts
    3

    Referencing an Opened Workbook (with variable in file name)

    What I am trying to do:
    1) Have user enter date, make the date a part of the file name and open that file.
    2) Once the file is opened, look at each tab, find due dates within 7 days, and copy the data to the corresponding "5 days lookahead" workbook.

    Please Login or Register  to view this content.

  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 an Opened Workbook (with variable in file name)

    You could add a variable that references the workbook being opened.

    For example, I've added the variable wbToday to this code and set it to refer to the workbook being opened.

    You can now use wbToday in any subsequent code when you want to refer to that workbook.

    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-15-2015
    Location
    Seattle
    MS-Off Ver
    Windows 10
    Posts
    3

    Re: Referencing an Opened Workbook (with variable in file name)

    Norie, thank you for replying.

    The Workbook with the date has been opened. What I want to do is to go to this workbook, copy some data.
    Then go back to the workbook (5 days lookahead) and paste it. Then go back and forth.

    My codings are:

    Please Login or Register  to view this content.

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

    Re: Referencing an Opened Workbook (with variable in file name)

    You can't select a workbook and a sheet in that workbook at the same time.

    Mind you, there's no need to select/activate anything to copy/paste.

    What range do you want to copy from Sheet1 of the workbook that's been opened?

  5. #5
    Registered User
    Join Date
    12-15-2015
    Location
    Seattle
    MS-Off Ver
    Windows 10
    Posts
    3

    Re: Referencing an Opened Workbook (with variable in file name)

    It's actually more complicated:

    1) So now my working workbook (5days lookahead) and my data workbook (Airframe Daily with date variable) are opened.
    2) I want to go to Daily, tab Tier 2 to find out how many rows of data I have.
    3) Then for anything with 3rd column with a date less than now() =7, I want to copy that row
    4) Then go to the 5 days workbook, Tier 2 tab, and paste that row to the row after the last record.

    Please Login or Register  to view this content.

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

    Re: Referencing an Opened Workbook (with variable in file name)

    Doesn't sound too complicated.

    Mind you all that, unneeded, selecting/activating does kind of make the code look complicated.

+ 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] Put name of every newly opened file into variable?
    By davepoth in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-20-2014, 08:18 AM
  2. Replies: 4
    Last Post: 04-21-2013, 10:53 PM
  3. Replies: 2
    Last Post: 04-12-2013, 07:56 PM
  4. Replies: 5
    Last Post: 03-21-2013, 07:34 AM
  5. [SOLVED] How to set variable to be opened word file
    By Alexander_Golinsky in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2012, 01:29 AM
  6. [SOLVED] Referencing an opened Workbook
    By BerkshireGuy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-18-2005, 06:05 AM
  7. Referencing an Opened Workbook
    By DaveUK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2005, 04:38 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