Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
To delete the rows if certain cells contain the following
Hi,
Eg.. If column A:A contains numbers like VA11111111, VA22222222, VA33333333 and VA00000000, I would like to write a simple macro that can delete the rows if cell column A:A contain the numbers.. Can anyone help.? ddiicc |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
To delete the rows if certain cells contain the following
Hi Ddice,
Try: #=========================== Public Sub TesterA1() Dim Rng As Range Dim rngDel As Range Dim rCell As Range Dim sh As Worksheet Dim arr As Variant arr = Array("VA11111111", "VA22222222", _ "VA33333333", "VA00000000") Set sh = ActiveSheet '<<===== CHANGE With sh Set Rng = Intersect(.UsedRange, .Columns("A:A")) End With For Each rCell In Rng.Cells If Not IsError(Application.Match(rCell.Value, arr, 0)) Then If Not rngDel Is Nothing Then Set rngDel = Union(rCell, rngDel) Else Set rngDel = rCell End If End If Next If Not rngDel Is Nothing Then rngDel.EntireRow.Delete End If End Sub '<<=========================== --- Regards, Norman "ddiicc" wrote in message ... Hi, Eg.. If column A:A contains numbers like VA11111111, VA22222222, VA33333333 and VA00000000, I would like to write a simple macro that can delete the rows if cell column A:A contain the numbers.. Can anyone help.? ddiicc |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Allow Delete cells but not rows | Excel Worksheet Functions | |||
delete rows with empty cells | Excel Discussion (Misc queries) | |||
Delete rows where cells contain various criteria | Excel Programming | |||
Delete Rows where all cells = 0 | Excel Programming | |||
Delete Rows where all cells = 0 | Excel Programming |