r/excel • • 20d ago

unsolved Count how many times a value of a cell is near another

Ok, I'm sure this is incredibly dumb. I set up a sheet probably too close to a physical piece of paper than I should have but it's come such a long way that I don't want any further changes. Basically, what I need to do is find how many times a value in a cell heading is near a certain number in another sheet.

For example, let's say the heading is called "Equipment", and I would like to know how many times the number 8 is 2 columns left and 1 row down from it, in the next sheet.

Can either an offset or xlookup do something like that?

4 Upvotes

18 comments sorted by

•

u/AutoModerator 20d ago

/u/howradisit - Your post was submitted successfully.

Failing to follow these steps may result in your post being removed without warning.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

9

u/AndyTheEngr 7 20d ago

I think we'll need a more visual example, but also this sounds like you need to back up a level and explain the problem you're trying to solve.

1

u/howradisit 20d ago

Sorry for the quick and dirty mockup

The picture is an example.

1

u/howradisit 20d ago

And here would be the sheet where the count happens

1

u/Clearwings_Prime 25 19d ago

Is this work for you?

=SUM( ( $D$2:$D$4 = "New York" ) * ( $F$1:$F$3 = "Equipment") )

1

u/excelevator 3071 20d ago

Your first two sentences in your post are irrelevant to your issue.

You have not given a clear example with expected result from given data.

4

u/carbonizedtitanium 2 19d ago

if this is actually how your data is set up, it's absolutely horrid:

the longer you keep using the bad foundation, the more future problems will compound.

4

u/carbonizedtitanium 2 19d ago

should really consider

3

u/fastauntie 1 19d ago

Agreed. Yes, it takes an annoying amount of time and effort to completely rearrange a workbook. And when that results in something that's easier and more efficient to use and less prone to error, it's worth every bit of the time and effort spent. I've done that in the last few years with several large and complicated files that I rely on, and it's now so much easier to enter data, generate new kinds of reports when they're needed, and teach other people to use them.

2

u/Just_blorpo 7 20d ago

In addition to what others have suggested, Sometimes a ‘helper’ column aids in setting this up.

Have an extra helper column that uses an IF statement and have it return either a ‘YES’ or a ‘NO’ if the row meets a certain criteria in relation to other cells. This can later make it easier to sum things up using a pivot table or other formulas. It really depends on what exactly you are trying to accomplish.

1

u/P1ckl3R1ck101 20d ago

Okay im not sure if this is what youre looking for, but could you use something simple like COUNTIFS($C$1:$C$1000,"Equipment",$A$3:$A$1002,8)? You'd change the range based on which columns/rows youre looking at. Basically you're offsetting the range of your countifs criteria based on the spacing.

1

u/Way2trivial 475 20d ago

sumproduct to find the address of fish

m16
=ADDRESS(SUMPRODUCT((A1:P12="fish")*ROW(A1:P12)),SUMPRODUCT((A1:P12="fish")*COLUMN(A1:P12)), 4, 1)

m17 find the address two over and one down from fish

=ADDRESS((SUMPRODUCT((A1:P12="fish")*ROW(A1:P12)))+1,(SUMPRODUCT((A1:P12="fish")*COLUMN(A1:P12)))+2, 4, 1)

1

u/Way2trivial 475 20d ago edited 20d ago

see content of row & column of destination
=INDEX(A1:K10,SUMPRODUCT((A1:P12="fish")*ROW(A1:P12))+1,SUMPRODUCT((A1:P12="fish")*COLUMN(A1:P12))+2)

now see if it matches an 8

=INDEX(A1:K10,SUMPRODUCT((A1:P12="fish")*ROW(A1:P12))+1,SUMPRODUCT((A1:P12="fish")*COLUMN(A1:P12))+2)=8

which comes back as true-- wrap it for numbering

=--(INDEX(A1:K10,SUMPRODUCT((A1:P12="fish")*ROW(A1:P12))+1,SUMPRODUCT((A1:P12="fish")*COLUMN(A1:P12))+2)=8)

and it will show a 1 for the page if 8 is 2 over one down

1

u/Decronym 20d ago edited 19d ago

Acronyms, initialisms, abbreviations, contractions, and other phrases which expand to something larger, that I've seen in this thread:

Fewer LettersMore Letters
ADDRESSReturns a reference as text to a single cell in a worksheet
COLUMNReturns the column number of a reference
COUNTACounts how many values are in the list of arguments
COUNTIFSExcel 2007+: Counts the number of cells within a range that meet multiple criteria
DROPOffice 365+: Excludes a specified number of rows or columns from the start or end of an array
FILTEROffice 365+: Filters a range of data based on criteria you define
GROUPBYHelps a user group, aggregate, sort, and filter data based on the fields you specify
IFSpecifies a logical test to perform
INDEXUses an index to choose a value from a reference or array
LETOffice 365+: Assigns names to calculation results to allow storing intermediate calculations, values, or defining names inside a formula
OFFSETReturns a reference offset from a given reference
ROWReturns the row number of a reference
SUMAdds its arguments
SUMPRODUCTReturns the sum of the products of corresponding array components
XLOOKUPOffice 365+: Searches a range or an array, and returns an item corresponding to the first match it finds. If a match doesn't exist, then XLOOKUP can return the closest (approximate) match.

Decronym is now also available on Lemmy! Requests for support and new installations should be directed to the Contact address below.


Beep-boop, I am a helper bot. Please do not verify me as a solution.
[Thread #49681 for this sub, first seen 13th Nov 2026, 20:28] [FAQ] [Full list] ^[Contact] [Source code]

1

u/semicolonsemicolon 1477 20d ago

Hi howradisit.

Here is a neat way to organize and count all of the cities at once, as long as your data looks exactly like what is in your sample. Replace `Sheet1` with whatever is the name of the sheet with the data.

The formula is =LET(z,FILTER(DROP(Sheet1!D:.D,1),DROP(Sheet1!F:.F,-1)=C1),GROUPBY(z,z,COUNTA))

It should result in the image you see above given data that appears as you have shown. If you don't want the total, or you want to order the cities by highest number to lowest, it's just a matter of playing with the optional arguments of the GROUPBY function.