Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AFPoster

macrumors 68000
Original poster
Jul 14, 2008
1,547
141
Charlotte, NC
I would like to know if this is possible and if anyone can tell me how to get this setup.

I have an excel document with 4 columns and over 16,000 rows. In Column A & B is an ID # and a Ticker. In C & D is a Ticker and an ID Number. I am basically trying to match the tickers together. So C&D columns go to 19,000 and A & B goes to 16,000. I have to remove 3,000 from the list. I've done this already but we lost the file so I am starting from scratch again. However I have the list of removed tickers on another document. So I know what needs to be removed.

The question: Is there any way to create an Automator script to remove the specific cells that I give the ticker for in just Column C & D. Seeing as I have the same tickers between B&C I don't want B to be touched.

I hope this makes sense, thanks!
 

waynep

macrumors 6502
Dec 31, 2009
434
0
Would probably be easier to write Visual Basic code inside Excel for this. I am learning some VB automate some Excel functions.
 

sero

macrumors member
Aug 28, 2008
91
14
if you can save as csv (or tsv, etc), this could be done with awk in terminal
Code:
man awk
 

jaduff46

macrumors 6502
Mar 3, 2010
328
187
Second star on the right....
Well, agree with Sero that awk would work. Join would also work if you have the UNIX utilities.

In Excel you can use MATCH and/or VLOOKUP. Syntax is MATCH(longer list ID, shorter ID list). If the longer list ID is in the shorter ID list, it will return the row number in the shorter ID list of the longer list ID, otherwise it will return #N/A.

VLOOKUP works in similar fashion, but allows you to grab another field from the shorter list (i.e. 2nd column) if there's a match on the id. If the shorter list is unordered, use FALSE as the last argument in the vlookup call.

All the rows with #N/A returned are rows in the longer list with no match in the shorter list. Sort the longer list by whether the function returned a match or #N/A, which would put all the unmatched rows in the longer list together to be deleted.

Have fun,
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.