Excel - Clearing Sheet Contents

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • markshowell
    New Member
    • Sep 2006
    • 2

    Excel - Clearing Sheet Contents

    I'm trying to use the following code to clear the contents of the two worksheets named Unpaid and Payments and then locate the cell pointer for that worksheet in cell A1 -

    Worksheets("Unp aid").Cells.Cle arContents
    Worksheets("Unp aid").Select
    Range("A1").Sel ect

    Worksheets("Pay ments").Cells.C learContents
    Worksheets("Pay ments").Select
    Range("A1").Sel ect

    However when I try and run the code I get the following error -

    Runtime error '1004'

    Select method of range or class failed

    Where am I going wrong?
  • NSF12345
    New Member
    • Aug 2006
    • 21

    #2
    it could be that the cells you are tryin to clear are protected? i remember having that problem in an assignment i had.

    Comment

    • markshowell
      New Member
      • Sep 2006
      • 2

      #3
      Originally posted by NSF12345
      it could be that the cells you are tryin to clear are protected? i remember having that problem in an assignment i had.
      No it does the clearing ok the error points at the range("a1").sel ect command

      Comment

      • kisnam
        New Member
        • Oct 2006
        • 3

        #4
        Hi im facing the same problem..

        i just want to clear all the content present in the excel sheet..from c# code.

        can any one track this problem?

        Comment

        • Froginator
          New Member
          • Feb 2007
          • 1

          #5
          Did you try..

          Worksheets("Unp aid").Cells.Cle arContents
          Worksheets("Unp aid").Cells(1, 1).Select

          Comment

          Working...