![]() |
matching items on 2 sheets
My macro pulls data into Sheet (B). Sheet (A) contains up-
to-date balances for some of the items on Sheet (B). Column A on each sheet contains a reference number. I want to look at each item on Sheet (A) and see if there is a match on Sheet (B). If there isn't a match, I want to delete the item on Sheet (A). I could start at the top of Sheet (A) and look through all of the reference numbers on Sheet (B) until I either get a match or get to the bottom of the list. If I get to the bottom of Sheet (B), I would delete the item on Sheet (A). There must be a better way than to cycle though Sheet (B) for each item on Sheet (A). Any suggestions or ideas would be greatly appreciated. As always, thanks for the help. |
matching items on 2 sheets
I dont personally agree with deleting data but if that is what you want here
goes... sub RemoveRows dim rngToSearch dim rngToFind as range dim rngFound as range set rngToSearch = sheets("SheetB").range("A1:A30") 'no idea how you know what to search for each rngTofind in rngToSearch set rngFound = sheets("SheetA").cells.find(rngTofind.value) do while not rngFound is nothing rngfound.entirerow.delete set rngFound = sheets("SheetA").cells.find(rngTofind.value) loop next rngToFind end sub or something like that... "JT" wrote: My macro pulls data into Sheet (B). Sheet (A) contains up- to-date balances for some of the items on Sheet (B). Column A on each sheet contains a reference number. I want to look at each item on Sheet (A) and see if there is a match on Sheet (B). If there isn't a match, I want to delete the item on Sheet (A). I could start at the top of Sheet (A) and look through all of the reference numbers on Sheet (B) until I either get a match or get to the bottom of the list. If I get to the bottom of Sheet (B), I would delete the item on Sheet (A). There must be a better way than to cycle though Sheet (B) for each item on Sheet (A). Any suggestions or ideas would be greatly appreciated. As always, thanks for the help. |
All times are GMT +1. The time now is 09:44 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com