View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Code Needed - new user

try this where your list is stored in an array

mm = Array(1, 2, 4)
For Each c In mm

--
Don Guillett
SalesAid Software

wrote in message
...
This solution still requires to keep the list of values in
b1:b3 (which I'm trying to avoid). Plus the range in
column A will be changing (row numbers can change). Is
there are any other solution that will loop thru column A
as long as there is data and compare the data to the list
of invalid accounts (but this list should not be saved as
a rangge in the workbook). Can it be coded in the body of
the macro somehow?
-----Original Message-----
try this where b1:b3 has your list and a21:a37 has the

rows to delete

Sub DeleteRowsInList()
For Each c In [b1:b3]
With Columns(1)
For r = 37 To 21 Step -1
With .Cells(r, 1)
If .Value = c Then .EntireRow.Delete
End With
Next
End With
Next c
End Sub

--
Don Guillett
SalesAid Software

"nat" wrote in

message
...
Hello,
Please help me to write a code to accomplish the

following:
.I have a list of account numbers listed in column A
(starting from the second row or A2)
.I need the macro to go down the list (while there is
still data) and determine if the account numbers are

valid
(against the list of invalid account numbers)
.And if it finds the invalid account number it should
delete the entire row

Of course I can determine the invalid accounts by using
the VLookUp function and then manually delete the rows

but
it would be great if it can be down automatically (via
macro).

Please help and thank you in advance.




.