ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting rows with specific value from row 1 to 200 (https://www.excelbanter.com/excel-programming/281411-deleting-rows-specific-value-row-1-200-a.html)

solo_razor[_23_]

Deleting rows with specific value from row 1 to 200
 

Hello,

I want to delete rows with specific values in column c and d. This
criteria must be done from row 1 to row 200.

Regards,
Niek


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


patrick molloy

Deleting rows with specific value from row 1 to 200
 
DIM keyvalue as double
DIM rw as long
keyvalue = 123.45
FOR rw = 200 TO 1 step -1
IF cells(rw,"C") = keyvalue _
OR _
cells(rw,"d") = keyvalue Then
Rows(rw).Delete
END IF
NEXT

Note that you need to move 'up' the sheet, hence the
reverse for/next loop. If you did a normal for next,
deleteing row 'n' would move row n+1 to row n, then
the 'next' statment would ponit to the new row n+1, so
the original n+1 row woul dbe 'skipped' over. Difficult
to explain. but try it and see.

Patrick Molloy
Microsoft Excel MVP


-----Original Message-----

Hello,

I want to delete rows with specific values in column c

and d. This
criteria must be done from row 1 to row 200.

Regards,
Niek


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

.



All times are GMT +1. The time now is 07:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com