ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro for auto deleting row if cell value = x (https://www.excelbanter.com/excel-programming/303493-macro-auto-deleting-row-if-cell-value-%3D-x.html)

nancee

Macro for auto deleting row if cell value = x
 
I'm looking for some visual basic help for the following scenario...

Column A contains cells values: x, y, z
I need macro to refer to column A, and delete entire row if cell value = y or z

I really appreciate your help! Thanks!

MSP77079[_38_]

Macro for auto deleting row if cell value = x
 
FirstRow = number of first row of data
myColumn = number of column that you want to examine
Set myRange = Cells(FirstRow, myColumn).CurrentRegion
LastRow = myRange.Cells(myRange.Cells.Count).Row

For myRow = LastRow to FirstRow step -1
if cells(myRow, myColumn) = "x" the
cells(myRow,myColumn).entirerow.delete
Next myRo

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 05:28 PM.

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