ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Newbie : Find / Find Next (https://www.excelbanter.com/excel-programming/281632-newbie-find-find-next.html)

Rich[_16_]

Newbie : Find / Find Next
 
I am using Excel 97.

I need to complish the following. I have a list of account numbers
that need to be deleted from a spreadsheet. The problem is that I
don't know how many instances of the account number is on the
spreadsheet, so I need to issue the find command again and again until
all account nubmers have been deleted. So the code might look like

1. get account number
2. find it on spreadsheet.
3. if found, delete that row.
4. continue until all instances of the account number are deleted.
5. go get next account number.

My question to you is, what is the best way to tell Excel to continue
looking for these values until all of them have been deleted.

Alan Beban[_4_]

Newbie : Find / Find Next
 
How about something like:

Set rng1=Range("deletable_number_list")
Set rng2 =Range("spreadsheet_account_number_list")
For Each iCell in rng2
If Application.Countif(iCell.value,rng1)0 then _ iCell.EntireRow.Delete
Next iCell

Alan Beban

Rich wrote:
I am using Excel 97.

I need to complish the following. I have a list of account numbers
that need to be deleted from a spreadsheet. The problem is that I
don't know how many instances of the account number is on the
spreadsheet, so I need to issue the find command again and again until
all account nubmers have been deleted. So the code might look like

1. get account number
2. find it on spreadsheet.
3. if found, delete that row.
4. continue until all instances of the account number are deleted.
5. go get next account number.

My question to you is, what is the best way to tell Excel to continue
looking for these values until all of them have been deleted.




All times are GMT +1. The time now is 12:43 PM.

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