Delete all Rows of data that do not contain currency and a certain term

torchD

New Member
Joined
Feb 20, 2015
Messages
9
Hey guys! First time posting here, hoping to hear some ideas from bright people such as yourselves
smile.gif
. I myself am pretty much a rookie when it comes to VBA's but I have played around with macros quite a bit. Anyways I work for a card store and a lot of our sales come from online. We like to keep our card's prices as updated as possible, this involves going to Amazon, looking each card's price up individually and updating it accordingly. This takes quite a lot of time and would be much easier if we could simply look at one spread sheet that contains all the updated prices. So I figured I should I'd play around in excel to see if I could come up with a way to accomplish this.

I have a macro set up that reads the data from the web into excel. Here is an example of a web page I pull data from:Amazon.com: Buying Choices: Pokemon Black & White Single Card Pikachu #115 Secret Rare
The problem is that a lot of junk comes along with the actual numbers I need. I have a spreadsheet to illustrate this. Basically I need to find a VBA code that deletes every row that does NOT have currency OR the term "total ratings" in it.

I've posted this on a few forums and received no help yet. If you want to download the sample spreadhseet you can find it on my post here: Cleaning up Data Scraped From the Web by Deleting Certain Rows

On my spreadsheet "sheet 1" is what the data looks like right after I pull it off the web and "sheet 2" is the end result that I am trying to achieve.

One of the things that make this problem very difficult for me is the fact that the data is going to change every time I pull it off the web because card prices are constantly changing and companies are listing cards cheaper than others at different times. It is not as simple as recording a macro that deletes rows:3-6 ,10-13 etc.


 
=if(isnumber(a2),a2,search("shipping",a2)) assuming a2 not a number will return a number or a n/a

=if(isnumber(a2),a2,if(iserror(search("shipping",a2)),"shipping not found","shipping found"))

not tested so number of brackets may be wrong
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Ok that is working. Thansk, you kick butt! I modified it to this so it reports the shipping price instead of "shipping found" :

=IF(ISNUMBER(A54),A54,IF(ISERROR(SEARCH("shipping",A54)),"shipping not found",A54))

Now how to I go about automating the process of deleting all the rows that have "shipping not found"
 
Upvote 0
i put in shipping not found for clarity, but now you run down the column and check if it contains shipping not found, if it does delete entire row

assuming shipping not found is column c

for j=1 to 1000
if cells(j,3)="shipping not found" then goto 50 else goto 100
50 cells(j,3).select
here is the code for deleting an entire row
turn on macro record, delete an entire row, stop macro, examine and copy code and paste here
100 next j
 
Upvote 0
That code seems confusing to me, like I said I am a rookie with VBA's lol. I will play around with it and see what I can do.

I forgot to add the "total ratings" part into the formula you came up with. Should I add another IF statement at the end? Here's the current formula:

=IF(ISNUMBER(A54),A54,IF(ISERROR(SEARCH("$",A54)),"shipping not found",A54))

*I switched "shipping" in the ISERROR function to "$" bc it was returning phrases such as "Domestic shipping rates and return policy." which I do not want.

Thanks for all your help I really appreciate it.
 
Last edited:
Upvote 0
I tried this out and its not working:

=IF(ISNUMBER(A45),A45,(OR((IF(ISERROR(SEARCH("$",A45)),"shipping not found",A45)),IF(ISERROR(SEARCH("total ratings",A45)),"shipping not found",A45))))
 
Last edited:
Upvote 0
that code means if A45 is not a number, or something

=IF(ISNUMBER(A45),A45,IF(ISERROR(SEARCH("$",A45)),"shipping not found",A45)),IF(ISERROR(SEARCH("total ratings",A45)),"shipping not found",A45))))

still fails because if(iserror(search("$",a45),"shipping not found",a45) is a complete formula, you cannot launch another if

=IF(ISNUMBER(A45),A45,IF(ISERROR(SEARCH("$",A45)),"$ not found",IF(ISERROR(SEARCH("total ratings",A45)),"total ratings not found",A45))))

is what you need but I have not counted the brackets
 
Upvote 0

Forum statistics

Threads
1,225,385
Messages
6,184,647
Members
453,250
Latest member
unluckyuser

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top