Results 1 to 7 of 7

Error 1004 - 'select method of worksheet class failed'

This is a discussion on Error 1004 - 'select method of worksheet class failed' within the Excel Questions forums, part of the Question Forums category; Can anyone tell me why this code produces the error message above? Sheets("Data").Select Rows("2:2").Select Selection.copy Sheets("Hist").Unprotect ---this row causes problems ...

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    34

    Default

    Can anyone tell me why this code produces the error message above?

    Sheets("Data").Select
    Rows("2:2").Select
    Selection.copy
    Sheets("Hist").Unprotect

    ---this row causes problems -----
    If Worksheets("Hist").Visible = True Then Sheets("Hist").Visible = True
    ---------------------------------
    Sheets("Hist").Select
    Range("A1").End(xlDown).Offset(1, 0).Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False
    Application.CutCopyMode = False
    ActiveWorkbook.Save
    Sheets("Hist").Visible = False

    That part of it I recorded cos I,ve started having problems with it, and it worked ok twicw and now I have problems with it again. This is the only thing stopping a nice app from working!

    Thanks

  2. #2
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339

    Default

    does : -

    If Worksheets("Hist").Visible = False Then Sheets("Hist").Visible = True
    Sheets("Hist").Select

    work OK?

  3. #3
    New Member
    Join Date
    Mar 2002
    Posts
    34

    Default

    It used to... about an hour ago. Then stopped and I get the 1004 now. I don't get it - I recorded that bit!


  4. #4
    New Member
    Join Date
    Mar 2002
    Posts
    34

    Default

    Doh! I realised the mistake as I hit the Submit button! Ok - so that bit's ok, now I get the 1004 on the last bit -

    Sheets("Hist").Visible = True

    but it says - Unable to set the Visible property on the Worksheet class.
    Am I missing something here?

    [ This Message was edited by: matthewh on 2002-05-29 05:46 ]

  5. #5
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339

    Default

    Is your workbook protected? If so, i think you'll have to unprotect it first.

  6. #6
    New Member
    Join Date
    Mar 2002
    Posts
    34

    Default

    It unprotects it a couple of lines above that, then re-protects it. It's a history of some transactions that I can't have people changing.

  7. #7
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339

    Default

    You're unprotecting your worksheet there, but is your actual workbook protected, as this can prevent your sheets from being hidden and unhidden?

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
  •  


DMCA.com