Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: Run Time Error 1004

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    HI,

    I have already taken advice for this problem but it still cuses errors.

    I have the code

    Sub Button157_Click()
    Sheets("Sheet2").Rows("2").ClearContents
    Sheets("Sheet4").Rows("2").ClearContents
    End Sub

    It works, but only at the second time of asking. The first time - I get the run time error message. I click 'end' try again and everything is fine.

    What could be causing this?

    THanks

  2. #2
    Board Regular Steve Hartman's Avatar
    Join Date
    Feb 2002
    Location
    Houston,Texas
    Posts
    417
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I seem to remember something about 1004 in Microsoft's Knowledge base when I was poking around for another problem. You might want to look there.

  3. #3
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I had a quick look, the error differs between xl97 and xl2000. And this error captures a lot of different types of errors in xl97, could you type the description you get with the error?

    Nate

  4. #4
    New Member
    Join Date
    Mar 2002
    Posts
    24
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi,

    thanks for helping,

    I get the message

    'run time error 1004

    clearContents method of range class failed'

  5. #5
    Legend NateO's Avatar
    Join Date
    Feb 2002
    Location
    Minneapolis, Mn, USA
    Posts
    9,700
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Matty,

    there seems to be an issue with the a1 reference style, which we can explore in more detail if this doesn't work, but try the following code first:

    Sub Button157_Click()
    Worksheets("Sheet2").Rows("2").ClearContents
    Worksheets("Sheet4").Rows("2").ClearContents
    End Sub

    I've seen Excel get finicky on the sheets vs. worksheets before.

    If you're in XL97 and running the macro from a "Chart Sheet" you may want to select a different worksheet at the beginning of your code and return to it at the end. Last resort is to actually select the worksheets before clearing the respective contents. We'll turn the screenupdating to false, it shouldn't dampen performance time too much.

    Hope this helps.

    Cheers, Nate

    [ This Message was edited by: NateO on 2002-03-12 08:51 ]

  6. #6
    Rest in Peace
    Join Date
    Feb 2002
    Posts
    1,582
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi

    Set the TakeFocus******* Property of the CommandButton to False, or use one from the "Forms" toolbar

    _________________
    Kind Regards
    Dave Hawley
    OzGrid Business Applications
    Microsoft Excel/VBA Training


    [ This Message was edited by: Dave Hawley on 2002-03-12 08:50 ]

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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