Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow Delete cells but not rows Elton Law[_2_] Excel Worksheet Functions 1 April 30th 09 10:53 AM
delete rows with empty cells Slohcin Excel Discussion (Misc queries) 14 December 19th 06 05:14 PM
Delete rows where cells contain various criteria gmunro Excel Programming 1 March 10th 05 02:27 PM
Delete Rows where all cells = 0 William[_2_] Excel Programming 0 August 11th 04 04:34 PM
Delete Rows where all cells = 0 Ron de Bruin Excel Programming 0 August 11th 04 04:23 PM


All times are GMT +1. The time now is 06:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"