+ Reply to Thread
Results 1 to 6 of 6

Select methof of range class failed (1004)

  1. #1
    Registered User
    Join Date
    01-29-2007
    Posts
    92

    Select methof of range class failed (1004)

    I have piece of code that is giving me problems.

    Please Login or Register  to view this content.
    The sheet it refers to is hidden (not very hidden). The code sometimes works and sometimes it returns the generic 1004 error which is the most frustrating thing.

    Anyone know what i could be doing wrong, some time of setting maybe?

    Cheers
    Bruno

  2. #2
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    you cannot select a hidden sheet without first unhiding it!, i suggest you don't select it at all, how about using a with statement?
    i.e
    With Sheets("Sheet1").Cells
    .Cells.Value = "Fred" ''''''change all cells to show "Fred"
    End With
    Not all forums are the same - seek and you shall find

  3. #3
    Registered User
    Join Date
    01-29-2007
    Posts
    92
    Alright thank you i'll try that. But why does it work sometimes?

    Also, I tried to unhide the sheet to see if it would work then, but it still gives me the error on the second line regardless of whether the sheet is hidden or not. Also, the code works fine until i set application.updating to manual and back to automatic. After i set it to automatic, the code stops working.
    Last edited by Schwizer; 05-09-2007 at 02:04 PM.

  4. #4
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Schwizer, i cant answer that!, a glitch, a bug or maybe to do with using sheet codename i.e sheets(1) rather than sheet name Sheets("Sheet1")

  5. #5
    Registered User
    Join Date
    01-29-2007
    Posts
    92
    Hmm, alright. Well basically all i want to do is find a cell on a hidden sheet using the search function.

    How would i go about finding and selecting a cell called "456 Series" on a hidden sheet called "Motors"

    Cheers
    Schwizer

    Note: Excel only has one bug, it's the user
    Last edited by Schwizer; 05-09-2007 at 02:19 PM.

  6. #6
    Forum Expert Simon Lloyd's Avatar
    Join Date
    03-02-2004
    Location
    locked in the cage
    MS-Off Ver
    All the ones my homepage shows
    Posts
    3,161
    Well using the find method the sheet must be visible and active like below:
    Please Login or Register  to view this content.
    but with the above method the sheet is unhidden and hidden again without the user being aware!

    You could declare Mc as a public string then once found it will be available in any module as that value

    Please Login or Register  to view this content.
    this way of declaring Mc as a public string can only be done in a standard module, you cannot declare a public string in a private module like a Userform

+ 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