+ Reply to Thread
Results 1 to 4 of 4

Define variable as range in a closed workbook

  1. #1
    Registered User
    Join Date
    09-23-2014
    Location
    Washington, DC
    MS-Off Ver
    2011
    Posts
    92

    Define variable as range in a closed workbook

    Hi All,

    New to VBA and working on a few UDFs to speed up my day-to-day banality. I'm trying to reference a fixed range in an unopened workbook. Do I need to include the path to the file, and what would the syntax look like? Or can I get away with

    rngReturn = Workbooks("Test.xlsx").Sheets("Sheet1").Range("$A$2:$A$10"), where rngReturn is a range


    Thanks!

    Alex

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

    Re: Define variable as range in a closed workbook

    You need to open the workbook for that syntax to work. Workbooks("...") refers to the collection of open workbooks.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    09-23-2014
    Location
    Washington, DC
    MS-Off Ver
    2011
    Posts
    92

    Re: Define variable as range in a closed workbook

    Ahh okay. Is there any way to make it work with the workbook closed?

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

    Re: Define variable as range in a closed workbook


+ 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. using a variable workbook's name to define another variable
    By lordterrin in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-30-2013, 05:57 PM
  2. [SOLVED] How can define a range with a set variable?
    By s4driver in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2013, 12:16 PM
  3. UDF - How to define a variable range?
    By irisqueiroz in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-19-2013, 10:56 AM
  4. [SOLVED] Define Variable as Range
    By Jiptastic in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-02-2013, 03:28 PM
  5. Using a variable to define a range in VBA
    By MysticGenius in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2011, 06:20 PM
  6. How to use a variable to define a range?
    By papermoon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-21-2010, 03:18 PM
  7. SUMPRODUCT to SUM variable range in closed workbook
    By opopanax666 in forum Excel General
    Replies: 2
    Last Post: 02-12-2010, 06:42 AM
  8. Define Range Name with variable row value
    By wayliff in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-17-2006, 11:23 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