Home > Mobile >  IF statement to turn positive values into negative values in Excel
IF statement to turn positive values into negative values in Excel

Time:01-26

I have a dataset of lat/lon coordinates in Excel, but some of the coordinates were improperly entered. What would be the Excel code to change a positive coordinate to a negative one (and leave negative values as they are)?

latitude    longitude
25.66632    -80.26313
25.65948    80.26483
25.64070    -80.27083
25.63548    -80.27487
25.63320    80.27678
25.63137    -80.27763

CodePudding user response:

If longitude data is in column C (from C2 onwards, say) - then you can deploy a couple of synonymous techniques - depending upon your preference:

  1. =if(C2>0,-C2,C2) : perhaps most intuitive
  2. =-abs(C2) : parsimonious, kudos to Jadefalke (26/01/22 - commentary)

Array functions exist for these too - i.e. for a column of data C2:C10, you can enter (once) in the corresponding leading (top) cell =-abs(C2:C10). see here for details RE: Office 365 compatible vs. prior versions of Excel.

  •  Tags:  
  • Related