+ Reply to Thread
Results 1 to 9 of 9

Access to ranges in hidden sheets

Hybrid View

  1. #1
    Registered User
    Join Date
    06-29-2006
    Posts
    16

    Access to ranges in hidden sheets

    Hello,

    Within VBA I want to get access to the data in ranges on hidden sheets. Is this possible while keeping these sheets hidden?
    Best regards,

    g

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Yes

    In the ame way that you get data from any sheet. Just because it is hidden does not mean you can not work with it.

    You do not need to activate or select books, sheets, rows, columns, cells etc to work with them

    sheets("sheet2").range("a1:c5").copy
    activesheet.paste
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Registered User
    Join Date
    03-13-2007
    Location
    Metro Atlanta
    Posts
    48
    Mudraker,

    Extracting a cell value from a hidden workbook with VB code could be very useful! What would be the syntax for [the workbook] in the string below?

    ActiveSheet.Range("A1") = [the workbook]Sheets("Sheet1").Range("A1")

    Thanks!

  4. #4
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Just add the workbooks(???) before sheets(???)
    Remember that until a book is saved it does not have .xls as part of its name

    ActiveSheet.Range("A1") = workbooks("book1.xls").Sheets("Sheet1").Range("A1")
    You cann also use a variable to refer to a book by name. Replace "book1.xls" with the variable name - no " required

    or you can set a variable to become a book or a sheet

    dim wS as worksheet
    set wS = workbooks("book1.xls").Sheets("Sheet1")
    ActiveSheet.Range("A1").value  = wS.range("a1").value

  5. #5
    Registered User
    Join Date
    06-29-2006
    Posts
    16
    Thanks. The attached example might make things clearer. I want to read the first cell in the range myRange on Sheet2. Sheet2 is made hidden at the start of the test sub.
    Thanks much!

    g
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-29-2006
    Posts
    16

    Understood

    mudraker:

    Understood!
    Thanks again,

    g

  7. #7
    Registered User
    Join Date
    03-13-2007
    Location
    Metro Atlanta
    Posts
    48
    g,
    Please excuse the encroachment.

    Mudraker,

    That's great info. It appears to work in the reverse as well...it writes to the hidden workbook w/o messing with screenupdating, etc.

    I probably could have saved 10MB of my 40MB, 29 worksheet "program" (THE INTERPRETER) had I known more tricks!

    See my stuff at http://www.e-linq.com/New_ElinQ/index.php (soon to be published)

    Can you also tell me if there is a way in Excel VB to check if a specified Excel file exist in my web?
    As far as I can see, the Dir Function will only work with local files...but maybe I haven't hit on the proper syntax of the string.
    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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