Consulting

Results 1 to 12 of 12

Thread: Question about clear, clear contents

  1. #1
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location

    Question about clear, clear contents

    I’m using a macro to clear a range of cells If I use clear or clear contents my macro doesn’t work anymore. If I use the delete key on the keyboard and paste other values into those cells then the macro works. Can’t figure out why?
    Peace of mind is found in some of the strangest places.

  2. #2
    Please show your macro and tell us on what line you get which error exactly.
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Quote Originally Posted by Jan Karel Pieterse View Post
    Please show your macro and tell us on what line you get which error exactly.
    the macro runs fine. Here is what I’m doing.

    I copy and paste from a csv workbook into a macro enabled workbook. In the code there is a line that changes the csv to double (CDbl). Like I said it works fine the first pass and also works if you use the delete key to delete the data and replace it with new csv data.

    I created a macro that that clears the data from a actixeX button. This is where the problem comes in. If I use ClrarContents or Clear the paste the csv data and run the macro it does not find matches but it should.

    So the question is why does the macro run correctly when you use the delete key to clear the contents but if you use the macro to clear contents the next time you paste the data and run the macro no matching data is found. To me delete key or clear or clear contents is the same. But obviously not.
    Peace of mind is found in some of the strangest places.

  4. #4
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    Hi austenr. I see the CDbl code revision worked. Maybe post your macro that you're using to clear/delete the data. Dave

  5. #5
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Quote Originally Posted by Dave View Post
    Hi austenr. I see the CDbl code revision worked. Maybe post your macro that you're using to clear/delete the data. Dave
    Private Sub CommandButton1_Click()
    Range("a2:a1000").ClearContents
    End Sub
    basically just that 1 line. Also tried clear contents.

    I would also like a way to copy cells in column A that have an X in column B which indicates a match to E8 and all subsequent matches on down so the user doesnt have to scroll down all the way. I know there is an offset way of doing it but cant get it to work.
    Peace of mind is found in some of the strangest places.

  6. #6
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    Maybe just append some code to the previous code. Where do U want to list the matches? U need to qualify your clear...
    Dim LastRow As Integer
    'clear "A"
    With Sheets("Sheet1")
    LastRow = .Range("A" & .Rows.Count).End(xlUp).Row
    .Range("A" & "1:A" & LastRow).Clear
    End With
    Dave

  7. #7
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    You have so little knowledge of VBA that anything is possible in 'your' code.
    My compliments for not uploading your workbook and preventing others to help you.

  8. #8
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    hello dave the matches should start in E8. as for the response from snb sometimes its better to say nothing and move on to the next thread instead of trying to belittle someone.
    Peace of mind is found in some of the strangest places.

  9. #9
    VBAX Expert Dave's Avatar
    Joined
    Mar 2005
    Posts
    835
    Location
    "You have so little knowledge of VBA that anything is possible in 'your' code." ????? snb seems like you were referring to me but I'm guessing U were just funning with austenr. I'll pm austenr with anything further. Dave

  10. #10
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    @Dave the you in the second line is the same you in the first one (i.e. not you)

  11. #11
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Quote Originally Posted by snb View Post
    @Dave the you in the second line is the same you in the first one (i.e. not you)
    Snb. So if it’s not Dave and your going after me
    Then I give nary a F about you. It’s people like you that give places a bad name.
    Peace of mind is found in some of the strangest places.

  12. #12
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,642
    Also tried clear contents.
    Brrrr. Too lazy to use F1.

Posting Permissions

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