|You mentioned sometimes needing to the "number of occurrences of 2 specific numbers, up to 5 specific numbers." |
Where will the criteria for each run be found? Will you put those numbers in a range of cells or enter them from the keyboard?
The code could be written to read a range of cells for the input criteria or it could present a series of "Input Boxes" for the user to enter the criteria into.
You said the spreadsheet has thousands of entries. Thousands of rows that look like your example or thousands of columns or thousands of both?
That's the kind of specifics I mean.
Make believe that I am sitting way over here where I can't see your spreadsheet or know what process you are following. The more details you supply, the better the odds that the solution offered will be work right the first time.
VBA - Visual Basics For Applications
It is essentially Visual Basic, but each MS Office application has a specific version of VBA with instructions that only work within that application. Since the VBA language is very specific, just like an Excel formula, it needs to know where to look for the input data, what to do with it, what range to search in, where to put the output, etc.
For example, your original data has no Row or Column labels. I would need to know where the data is on the spreadsheet - or at least the starting cell. As long as there is nothing below the data or to the right of it, there are VBA commands that can determine the last Row and/or Column that has data in it. Once that's known the code can determine the aea to be searched for your criteria - assuming it also knows where to get the criteria from.
For example, this code will search B1:J15 for the value in A1 and place the address in A2:
'Get Value To Search For
myVal = Range("A1")
'Set Search Range
'Search For Value
Set v = .Find(myVal)
'Output Address or Message To A2
If Not v Is Nothing Then
Range("A2") = v.Address
Range("A2") = "Value Not Found"
You'll note that I had to tell the code where to find the input, what range to search and where to put the output.
Click Here Before Posting Data or VBA Code ---> How To Post Data or Code.