Share via

Auto delete in Excel

Anonymous
2014-06-13T16:29:33+00:00

Is it possible to accomplish the following scenario?

  1. G2 has an "X" in the cell
  2. Once my imported data causes H2 to have a higher value than J2, I would like for the "X" in G2 to be automatically deleted. Obviously, I have 100's of rows that need to be able to do that, not just row 2.

What I have is this:

When my "available qty" falls below the MIN, it turns the cells red. When I order those, I put an x in the Ordered column and it turns it back to green so I don't have to keep looking at it in the red. I filter by red so I know what I need to order. I just want an automatic way for the x to be deleted once the available qty is more than the min.

Thanks.

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2014-06-14T13:38:12+00:00

I see where you're going with that but it's not quite what I need.

I have to manually put the x's in when I've ordered parts. I want the x's to automatically delete once H is higher than J.

Hi,

You need vb code for that. Right click the worksheet tab where you want this, view code and paste the code in on the right.

The code will execute for any change on the worksheet but that should not give a problem

Private Sub Worksheet_Change(ByVal Target As Range)

Dim LastRow As Long, c As Range

LastRow = Cells(Rows.Count, "H").End(xlUp).Row

Application.EnableEvents = False

For Each c In Range("H2:H" & LastRow)

    If c.Value > c.Offset(, 2) Then

        c.Offset(, -1).ClearContents

    End If

Next

Application.EnableEvents = True

End Sub

Was this answer helpful?

0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Anonymous
    2014-06-23T14:37:21+00:00

    This is actually causing my spreadsheet to lock up occasionally.

    Can this be accomplished with a manually ran macro instead?

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-06-14T13:58:31+00:00

    I think that may work.

    Thank you.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2014-06-14T13:13:00+00:00

    I see where you're going with that but it's not quite what I need.

    I have to manually put the x's in when I've ordered parts. I want the x's to automatically delete once H is higher than J.

    Was this answer helpful?

    0 comments No comments
  4. Ashish Mathur 101.9K Reputation points Volunteer Moderator
    2014-06-13T23:33:42+00:00

    Hi,

    In cell G2, enter this formula and copy down

    =IF(H2<=I2,"X","")

    Hope this helps.

    Was this answer helpful?

    0 comments No comments