Macro:- Deleting rows on condition for selected no of col.

[Closed]
Report
Posts
1
Registration date
Sunday October 5, 2014
Status
Member
Last seen
October 5, 2014
-
Posts
2783
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
August 3, 2021
-
Hi.

I have an excel for which i require to delete rows if there is "n" found in the row. But i want this row to get deleted for only a particular number of column.

I have attached a screenshot of my requirement. Please guys help me figure out this.

1 reply

Posts
2783
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
August 3, 2021
468
Hi ShridharSahu,

Your screen capture is a little too big to fit in a thread. This makes it very hard to read.

You say you want to delete rows which contains a "n", but only for a particular number of columns. Since you didn't specify the range try this example:

Sub RunMe()
For Each cell In Range("A1:F20")
    If cell.Value = "n" Then Range(Cells(cell.Row, "A"), Cells(cell.Row, "F")).Delete
Next cell
End Sub


When a "n" is found in the range A1:F20 then the columns A:F of that particular row will be deleted.

Best regards,
Trowa

Subscribe To Our Newsletter!

The Best of CCM in Your Inbox

Subscribe To Our Newsletter!