+ Reply to Thread
Results 1 to 3 of 3

Referencing to sheet (name) property of other files

  1. #1
    Registered User
    Join Date
    03-26-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    75

    Referencing to sheet (name) property of other files

    Hi All,

    Recently I embraced to use of VBA sheet (name) propety which allows me to reference sheets without the use of 'Sheets("Sheet label").range("A1")' but instead directly refer to the sheet name in VBA as in: 'Sheetname.range("A1")'. This allows end users to rename sheets without breaking the code.

    Now for my question / issue. When I reference sheets named in VBA in other workbooks then I get error '438': Object doesn't support this property or method. For example, I reference: OpenedSourceFile.Sheetname.Range("A1") and I get this error but when I reference OpenedSourceFile.Sheets("Sheet label").Range("A1") then it works. It seems this more sophisticated methode of referencing sheet doesnt work across different workbooks.

    Am I correct to assume that I can't reference the sheet (code) name? And are there any alternatives? I would hate to go back to Sheets("sheet label") since I know end users will start switching sheets around and renaming them at some point.

  2. #2
    Forum Expert
    Join Date
    08-02-2013
    Location
    Québec
    MS-Off Ver
    Excel 2003, 2007, 2013
    Posts
    1,412

    Re: Referencing to sheet (name) property of other files

    Hello,

    To my knowledge, you cannot use a sheets CodeName when you reference a Sheet that is in a different Workbook to the one that the code resides.
    But here's a possible workaround:

    http://yoursumbuddy.com/using-worksh...her-workbooks/
    GC Excel

    If this post helps, then click the star icon (*) in the bottom left-hand corner of my post to Add reputation.

  3. #3
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Referencing to sheet (name) property of other files

    Quote Originally Posted by Ronnet2 View Post
    Am I correct to assume that I can't reference the sheet (code) name?
    Correct. You cannot reference a sheet in an external workbook as a child object of that workbook using it's code name.


    are there any alternatives? I would hate to go back to Sheets("sheet label") since I know end users will start switching sheets around and renaming them at some point.
    This syntax is a round about way to reference an external workbook's sheet by its code name "Sheet1"
    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

+ 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] List all files in Directory and Subdirectory with File Property Details
    By Green Crocodile in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-26-2016, 09:59 PM
  2. [SOLVED] Referencing a UDF in Range.Formula Property - NAME#? Error???
    By ilsley_excel in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 02-08-2016, 11:01 AM
  3. Replies: 0
    Last Post: 01-09-2013, 06:58 AM
  4. [SOLVED] Referencing other files
    By PONJO in forum Excel General
    Replies: 7
    Last Post: 08-30-2012, 06:22 AM
  5. [SOLVED] Referencing other files
    By PONJO in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-30-2012, 04:13 AM
  6. [SOLVED] .formula property referencing a defined string constant
    By cwkoops in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-25-2012, 09:44 AM
  7. applying cross referencing between files?
    By jafooli in forum Excel General
    Replies: 4
    Last Post: 02-16-2012, 09:31 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