[b]Clearing Contents of Row and Moving all subsequent Rows Up

  • I have a macro using the change event. If an "x" gets typed into a certain cell, then the contents of the cells to the left gets cleared and the contents below get moved up so there is not a blank row in the range. All works fine except when I clear the contents of the cell that contains the "x", the change event gets triggered again in a continuous loop and all the cells are moved up and cleared one by one. However if I don't include the cell with the "x", then the "x" remains which I don't want to have happen. Does this make sense to anyone out there? There must be some simple work around.


    Thanks so much in advance!

    Thanks,


    Blue

  • Re: Clearing Contents of Row and Moving all subsequent Rows Up


    I will try my best to attach my workbook. I have never done that before and not sure how to do it. As you can see, I've just taken a first stab at this and only am testing one cell. The code will be modified as soon as I have things ironed out.


  • Re: [b]Clearing Contents of Row and Moving all subsequent Rows Up


    Hi,


    Note the two new lines:


    [vba]
    If IntersectRange1 = Range("J4") Then


    'Temporay disable Worksheet_Change event
    Application.EnableEvents = False


    Range("A4:j4").ClearContents
    Range("A5:j16").Copy
    Range("A4:j15").PasteSpecial xlPasteValues
    Range("A16:j16").ClearContents
    Range("A3").Select


    'Re-enable Worksheet_Change event
    Application.EnableEvents = False


    End If


    [/vba]


    PS: the closing tag for code is [ /code] (no space between square bracket and forward slash)


    Cheers,


    dr

  • Re: [b]Clearing Contents of Row and Moving all subsequent Rows Up


    Thanks so very much! Pretty simple solution, huh? I just couldn't find it...


    And thanks for the correction on posting code. I must have just spaced out the forward slash.


    Thanks again!

    Thanks,


    Blue

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!