You are here:

Excel/Tricky array formula


QUESTION: Hi Bob, Tom suggested I ask you a question.  I believe what I'm about to ask can be done via an array function, but I'm unclear how to write the function.

I'm dealing with an old spreadsheet that has a lot of data but no utility, and I'm trying to extract some information out of it.  The goal is to calculate the number of companies who have previously purchased from us by both state and year.  For example, Google could have offices in California and New York, and the New York office participated in 2012 and 2009, so I'd want to count it.  However, if the California office only participated in 2012, it wouldn't count.  We can assume at most 1 office per state.

I have 3 columns: Company, State and Year.  As described above, the Company name field is not unique, as companies can offices in multiple states.  Each line has Company, State, and Year all in the same spreadsheet, and there's about 20,000 lines which makes this just a gross use of Excel.

I hope I'm being clear, let me know if I'm not.


ANSWER: I don't understand why if the California office only participated in 2012, it wouldn't count.
Why wouldn't it?

---------- FOLLOW-UP ----------

QUESTION: The goal is to find repeat purchases by office location, so an acquisition in ONLY 2012 isn't interesting to me.  I need to find whether Google's California office, New York Office, etc. has purchased previously, regardless of year.  So, in the above scenario, we'd count New York because it purchased in both 2012 AND at least one prior year (could have purchased in multiple prior years, but at least 1 is sufficient), but we'd exclude California who only purchased in 2012.

If it helps, the years are from 2007 to 2012,

Sorry - still a little confused. You originally said you wanted to count the number of COMPANIES, yet later on you said "...we'd count New York because it purchased in both 2012 AND at least one prior year..." which seems to imply you're wanting to count LOCATIONS.
Please clarify.
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here


All Answers

Answers by Expert:

Ask Experts


Bob Umlas


I`m a Microsoft Excel MVP (Most Valuable Professional) and have been since the inception of the program in 1995. I can answer every kind of Excel question except: API, Importing/exporting to other programs (powerpoint, word,...) Also check out my in-person training link at


Worked with MS Excel since version 0.99 (on the Mac!). Was contributing editor to Excellence Magazine, having written >300 articles. John Walkenbach said of me "I finally met someone who knows as much about Excel as I do."

Excellence, The Expert, Microsoft

BA in math, Hofstra University, 1965

Awards and Honors
Led sessions for the Convergence 2004-2006 seminar on Excel tips & tricks

©2016 All rights reserved.