Ignore blanks in RADIANS distance calcluations

ollyhughes1982

Well-known Member
Joined
Nov 27, 2018
Messages
793
Office Version
  1. 365
Platform
  1. MacOS
Hi,

I have the following formula, which is calculating the set of coordinates that are closest to another given set of coordinates, from a list:

=IF(B3<>"",(SMALL(ACOS(SIN(RADIANS(E3))*SIN(RADIANS($E$3:$E$67))+COS(RADIANS(E3))*COS(RADIANS($E$3:$E$67))*COS(RADIANS($F$3:$F$67-F3))-1*10^-14)*6371,2)),"")

This formula works up until row 67, but then if I expand this downwards further into my range (where there are blanks, e.g. row 68 has a blank in E68) it gives me a value error. I want to expand my range to $E$3:$E$10002 (the extent of my range). So, what I need to know is, is there way to make the formula ignore blank entries and calculate from all populated ones?

FYI - The "blanks" I talk about are "" results from a formula, not true blanks - so there are formulas in those cells.

Thanks in advance!

Olly.
 
You can see they are set to a max range of ro 67 at the moment, which works as there are no gaps until 68, if you change it 68 or more then there is an error
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
On the Misc sheet, if I change EQ3 to:

Code:
=IF(OR(E68="",F68=""),"",IF(B3<>"",(SMALL(ACOS(SIN(RADIANS(E3))*SIN(RADIANS($E$3:$E$68))+COS(RADIANS(E3))*COS(RADIANS($E$3:$E$68))*COS(RADIANS($F$3:$F$68-F3))-1*10^-14)*6371,2)),""))

There is a blank (i.e., "") in the cell versus an error.

My confusion is why the formula is in EQ3 with an absolute cell reference in the Radian calculations. Would you continually change the 68 to the next value (e.g., 69) for future calculations?
 
Upvote 0
On the Misc sheet, if I change EQ3 to:

Code:
=IF(OR(E68="",F68=""),"",IF(B3<>"",(SMALL(ACOS(SIN(RADIANS(E3))*SIN(RADIANS($E$3:$E$68))+COS(RADIANS(E3))*COS(RADIANS($E$3:$E$68))*COS(RADIANS($F$3:$F$68-F3))-1*10^-14)*6371,2)),""))

There is a blank (i.e., "") in the cell versus an error.

My confusion is why the formula is in EQ3 with an absolute cell reference in the Radian calculations. Would you continually change the 68 to the next value (e.g., 69) for future calculations?
No, it will always be 10002 instead of 67 in each case; I just put 67 in to illustrate that it works until it encounters a "" cell
 
Upvote 0
Now I get it. I don't know the formula well enough to tell you what you should be multiplying by [ e.g., SIN(RADIANS($E$3:$E$10002) , etc.]
Maybe this:

Code:
=IF(B3<>"",(SMALL(ACOS(SIN(RADIANS(E3))*SIN(RADIANS(FILTER($E$3:$E$10002,ISNUMBER($E$3:$E$10002))))+COS(RADIANS(E3))*COS(RADIANS(FILTER($E$3:$E$10002,ISNUMBER($E$3:$E$10002))))*COS(RADIANS(FILTER($E$3:$E$10002,ISNUMBER($E$3:$E$10002))-F3))-1*10^-14)*6371,2)),"")
 
Upvote 0
Now I get it. I don't know the formula well enough to tell you what you should be multiplying by [ e.g., SIN(RADIANS($E$3:$E$10002) , etc.]
Maybe this:

Code:
=IF(B3<>"",(SMALL(ACOS(SIN(RADIANS(E3))*SIN(RADIANS(FILTER($E$3:$E$10002,ISNUMBER($E$3:$E$10002))))+COS(RADIANS(E3))*COS(RADIANS(FILTER($E$3:$E$10002,ISNUMBER($E$3:$E$10002))))*COS(RADIANS(FILTER($E$3:$E$10002,ISNUMBER($E$3:$E$10002))-F3))-1*10^-14)*6371,2)),"")
Thanks, I’ve had to pop out for a bit now, but will try later tonight or in the morning, as soon as I can. Thanks for your help so far.
 
Upvote 0
This has now been resolved in the Excel Forum post.

It worked with the addition of two LET functions within the formulas.

The formula for the original column is:

=IF(B3<>"",LET(a,FILTER($E$3:$E$10002,$E$3:$E$10002<>""),b,FILTER($F$3:$F$10002,$F$3:$F$10002<>""),IF(B3<>"",(SMALL(ACOS(SIN(RADIANS(E3))*SIN(RADIANS(a))+COS(RADIANS(E3))*COS(RADIANS(a))*COS(RADIANS(b-F3))-1*10^-14)*6371,2)),"")),"")

The adjacent formula is as follows:

=IF(B3<>"",LET(a,FILTER($B$3:$B$10002,$B$3:$B$10002<>""),b,FILTER($E$3:$E$10002,$E$3:$E$10002<>""),c,FILTER($F$3:$F$10002,$F$3:$F$10002<>""),IF(B3<>"",(INDEX(a,MATCH(EQ3,ACOS(SIN(RADIANS(E3))*SIN(RADIANS(b))+COS(RADIANS(E3))*COS(RADIANS(b))*COS(RADIANS(c-F3))-1*10^-14)*6371,0))),"")),"")

Thanks.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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