![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Board Regular
Join Date: May 2002
Posts: 251
|
Hi,
I want to creat a macro which is going to match values for me and delete rows. For Example in Column B "Alert" and in Column D I have "Reject". If in Column B I have any value and in column D I have nothing, then delete that entire row. if I have value in Column B and in column D, then keep it. for example row1: Alert Reject row2: Alert row3: Alert Reject I want to do some thing that it should delete row2. Please help me. Thanks in Advance. !!!!!!!! |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Apr 2002
Location: Greenwood, SC
Posts: 677
|
This code loops through the first 10000 rows and deletes what you want.
For i = 1 To 10000 If cells(i, 2).Value = "Alert" And cells(i, 4).Value = "" Then cells(i, 2).Select Selection.EntireRow.Delete i = i - 1 End If Next If you have a column which will always have data in it (example uses column A), you could add the following line directly after the for statement: If Cells(i,1).value = "" then exit for K |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: May 2002
Posts: 251
|
Thanks alot, thats really big help.
Thank you. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|