Excel VBA迭代三元组并添加负号

时间:2017-05-18 18:21:16

标签: excel excel-vba vba

我有一个kml文件的lat和long字符串,我想在下面的字符串中更改所有经度值为负值。

我认为最简单的方法是将它们放入三元组并迭代每一行并在第一个数字上添加一个负号。

latlong = "1.48638,54.9621256516623,0 1.48521523184216,54.9621324923351,0 1.48405081848398,54.9621530122697,0 1.48288711461705,54.9621872052157,0 1.48172447471685,54.9622350607575"

latlong = Replace(latlong, " ", vbCrLf)

1.48638,54.9621256516623,0

1.48521523184216,54.9621324923351,0

.....

-1.48521523184216,54.9621324923351,0

-1.48405081848398,54.9621530122697,0

非常感谢你的帮助。

1 个答案:

答案 0 :(得分:2)

试试这个

latlong = "-" & latlong
latlong = Replace(latlong, " ", vbCrLf & "-")