Consulting

Results 1 to 8 of 8

Thread: Writing to an xlveryhidden sheet

  1. #1
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location

    Writing to an xlveryhidden sheet

    another quiestion i probably should know the answer to by now.

    I am using a userform to display the contents of an excel spreadsheet that i keep very hidden, i currently unhide it paste my data and then rehide the sheet again within my code.

    Can anyone give me a basic example of how to write too a very hidden sheet and read from it without the need to make it visible hopefully speeding up my code?

    Thanks

    Gibbo

  2. #2
    Knowledge Base Approver
    The King of Overkill!
    VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Hi Gibbo,

    Rather than use copy/paste, you could use something like:

    Dim TheVeryHiddenSheet As Worksheet, TheVisibleSheet As Worksheet
     Set TheVeryHiddenSheet = Sheets("Sheet2")
     Set TheVisibleSheet = Sheets("Sheet1")
     TheVeryHiddenSheet.Range("A1:A30").Value = TheVisibleSheet.Range("A1:A30").Value

    Matt

  3. #3
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    Just specify the sheet name before the range. In fact you do not even need to make it visible to paste.

    Sheets("Sheet1").Range("A1").Value = 1 
    Sheets("Sheet2").Range("A1:B10").Copy Destination:=Sheets("Sheet1").Range("A1")

    In these examples, Sheet1 could be hidden or very hidden and it would not matter.

  4. #4
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    so if i set the work sheet before carrying out any of my actions actions on it i will never need to make it visible, to search, read or update, is that correct?

  5. #5
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    sorry posted before your reply Jake, I ll have a play with both methods, thanks

    Gibbo

  6. #6
    Knowledge Base Approver
    The King of Overkill! VBAX Master
    Joined
    Jul 2004
    Location
    Rochester, NY
    Posts
    1,727
    Location
    Jake,
    Though I can't duplicate it now, I had a problem once using the very hidden sheet in an Destination argument. May have been unrelated though.

    Gibbo,
    We're here if you need us!

  7. #7
    VBAX Expert
    Joined
    Jan 2005
    Posts
    574
    Location
    Thanks Again

    I have learnt loads since joining this forum and am just starting to be able to offer the odd bit of advice to others (Although only the odd bit at the moment)

    Your help is greatly appreciated

    Gibbo

  8. #8
    Site Admin
    Jedi Master
    VBAX Guru Jacob Hilderbrand's Avatar
    Joined
    Jun 2004
    Location
    Roseville, CA
    Posts
    3,712
    Location
    I double checked the code and it works fine on a very hidden sheet.

    Yes, if you specify the sheet name, you do not have to activate it or make it visible.

    You're Welcome

    Take Care

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •