complex (for mr anyway) if and statment

jtcsrvbi

New Member
Joined
Sep 18, 2014
Messages
4
i am working on a compass worksheet in excel. i enter in starting and ending Longitude and latitudes and it calculates distance. i have calculated the percent of 90 deg now i just need to put it in the right quadrant.

If Lat1 > 0 and if Lon1 >0 then Percent * 90 If Lat1 < 0 and If Lon1>0 then Percent * 90 +90

If Lat1 < 0 and if Lon1 <0 then Percent *90+180 If Lat1 > 0 and if Lon1 <0 then Percent *90+270








returned value


variables


Lat1
Lon1
Percent



thanks for taking a look!!

john
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,561
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
John,

Welcome to MrExcel.

You do not mention what happens if Lat1 or Lat2 = 0 ?

Given the conditions stated and with La1 in A, Lat2 in B2 and Percent in C2 then maybe....


Excel 2007
F
2270
Sheet3
Cell Formulas
RangeFormula
F2=(C2*90) +(IF(AND(A2>0,B2>0),0,IF(AND(A2<0,B2<0),2,IF(A2<0,1,3)))*90)


Hope that helps.
 

jtcsrvbi

New Member
Joined
Sep 18, 2014
Messages
4
i am trying to digest this... i converted a2, b2 and c2 to my variables. i got a 508 error. i am using open office but near as i can tell they are the same. you use "," and they use ";" this might be my problem


thanks for your help...
 

jtcsrvbi

New Member
Joined
Sep 18, 2014
Messages
4
i am trying to digest this... i converted a2, b2 and c2 to my variables. i got a 508 error. i am using open office but near as i can tell they are the same. you use "," and they use ";" this might be my problem


thanks for your help...

I got it!!!!:ROFLMAO:

=(Perc*90) +(IF(AND(Lat_val>0;Long_Val>0);0;(IF(AND(Lat_val<0;Long_Val>0);90;(IF(AND(Lat_val<0;Long_Val<0);180;(IF(AND(Lat_val>0;Long_Val<0);270))))))))

works perfect!!! thanks Tony for help with the syntax!!!
 

Snakehips

Well-known Member
Joined
May 17, 2009
Messages
5,561
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Glad I was able to give you a nudge in the right direction.
I did not appreciate that you were using named ranges and that your separator was semi-colon.

It really doesn't matter but can your formula not reduce to...

=(Perc*90) +(IF(AND(Lat_val>0;Long_Val>0);0;IF(AND(Lat_val<0;Long_Val>0);90;IF(AND(Lat_val<0;Long_Val<0);180;270))))
 

jtcsrvbi

New Member
Joined
Sep 18, 2014
Messages
4
i see... i don't need to do the last check because if the other 3 failed it must be 4... thanks again... i really learned a lot!!


john
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,302
Messages
5,836,516
Members
430,437
Latest member
Emilycr

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
Top