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

Thread: Importing data to a differnet worksheet, than the Cmd button

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi all. What I am trying to do is have a comand buton on Sheet1, clear a range on sheet 2. This is what I have and it dont seam to work. (button in sheet1)

    Private Sub Cmd1_Click()
    Sheets("Sheet2").Select
    Range("A1:D12").Select
    Selection.ClearContents
    Range("A1").Select
    End
    End Sub

    I also tryed the same thing with a dbase query, and it does the same thing. As long as I run the button from the same sheet that I want to import the data too, everything is fine. But when running the comand from another worksheet,In the same workbook I end up with errors.
    Thx for your help Dan

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    NY
    Posts
    1,056
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try appending Sheets("Sheet2") in front of each line, and don't change sheets:
    Private Sub Cmd1_Click()
    Sheets("Sheet2").Range("A1:D12").ClearContents
    End Sub

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Ok will try Thx again Bob, Have a good evening !

  4. #4
    Board Regular
    Join Date
    Mar 2002
    Location
    Arkansas
    Posts
    358
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Works Great Bob, Thx for your time !

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
  •