简体   繁体   English

在 Excel 中将正值转换为负值的 IF 语句

[英]IF statement to turn positive values into negative values in Excel

I have a dataset of lat/lon coordinates in Excel, but some of the coordinates were improperly entered.我在 Excel 中有一个纬度/经度坐标数据集,但某些坐标输入不正确。 What would be the Excel code to change a positive coordinate to a negative one (and leave negative values as they are)?将正坐标更改为负坐标(并保持负值不变)的 Excel 代码是什么?

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

If longitude data is in column C (from C2 onwards, say) - then you can deploy a couple of synonymous techniques - depending upon your preference:如果经度数据在 C 列中(例如,从 C2 开始) - 那么您可以部署一些同义技术 - 取决于您的偏好:

  1. =if(C2>0,-C2,C2) : perhaps most intuitive =if(C2>0,-C2,C2) :也许是最直观的
  2. =-abs(C2) : parsimonious, kudos to Jadefalke (26/01/22 - commentary) =-abs(C2) : 简约,对 Jadefalke 表示敬意 (26/01/22 - 评论)

Array functions exist for these too - ie for a column of data C2:C10, you can enter (once) in the corresponding leading (top) cell =-abs(C2:C10).这些也存在数组函数——即对于一列数据 C2:C10,您可以在相应的前导(顶部)单元格 =-abs(C2:C10) 中输入(一次)。 see here for details RE: Office 365 compatible vs. prior versions of Excel.有关详细信息,请参阅此处RE:Office 365 兼容与 Excel 的先前版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 JQuery if带有负值和正值的语句 - JQuery if statement with negative & positive values 使用 IF 语句分离从文本文件中读取的负值和正值 - Using IF statement for separating negative and positive values read from text file C ++:IF / ELSE比较带有正负值 - C++: IF/ELSE comparisons with positive & negative values 我正在使用if / else语句将数据集分成正/负值,但遇到了未使用的参数错误 - I'm utilizing an if/else statement to separate a data set into positive/negative values but have ran into an unused argument error 连续折叠数组,直到它包含替代的正负值 - Successively collapse array till it contains alternative positive and negative values Excel:IF和AND语句用于日期,空白和值 - Excel: IF and AND statement for dates, blanks and values If-Else语句-正整数和负整数 - If-Else Statement-Positive and Negative Integers SSRS如何将If和format语句一起用于负值 - SSRS how to use If and format statement together for negative values 如何基于R中的if条件语句重新编码一组变量中的负值? - How to recode negative values in a set of variables based on if conditional statement in R? 如何在Excel中创建具有多个值的条件语句 - How to create a conditional statement with multiple values in excel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM