Hi all, I am writing some code to fix up some survey information. The type of data I receive has a x, y and z co-ordinates for the same points, lets say a shot at the ground line, a shot at the top of a structure and shots part way up the structure. The software that will be importing this data can't handle the z values above ground, so I need to examine all the shots, make sure the x and y co-ordinates are exactly the same and then put in the z value of the ground and add a height of the upper shots. So I plan to do a data sort to get all the co-ordinates in the same area and then find all shots at that co-ordinate and then search for the ground shot (which will be the lowest z value) and then subtract that value from the other shots to create a height and then replace their current z value to the same z value of the ground. I have it working now where there are always 3 shots, but in future this may not be the case, so i wanted to future proof it. This is my coding now where the ground shot is always the lowest in the ascending order (once again not sure if this will always be the case) Any ideas. Still new to coding....polecount is my variable from a countA(range) value obtained earlier in the macro
Range("A1", "D" & polecount).Sort _ Key1:=Range("A1"), Order1:=xlAscending
condcnt = 1
Do While condcnt <= polecount
featcode = Range("D" & condcnt)
If featcode = "%yl" Then
Range("E" & condcnt).Value = Range("D" & condcnt).Value & Range("C" & condcnt) - Range("C" & condcnt + 1)
Range("C" & condcnt).Value = Range("C" & condcnt + 1)
ElseIf featcode = "%yt" Then
Range("E" & condcnt).Value = Range("D" & condcnt).Value & Range("C" & condcnt) - Range("C" & condcnt + 2)
Range("C" & condcnt).Value = Range("C" & condcnt + 2)
Else: Range("E" & condcnt).Value = Range("D" & condcnt).Value
End If
condcnt = condcnt + 1
Loop
Range("A1", "D" & polecount).Sort _ Key1:=Range("A1"), Order1:=xlAscending
condcnt = 1
Do While condcnt <= polecount
featcode = Range("D" & condcnt)
If featcode = "%yl" Then
Range("E" & condcnt).Value = Range("D" & condcnt).Value & Range("C" & condcnt) - Range("C" & condcnt + 1)
Range("C" & condcnt).Value = Range("C" & condcnt + 1)
ElseIf featcode = "%yt" Then
Range("E" & condcnt).Value = Range("D" & condcnt).Value & Range("C" & condcnt) - Range("C" & condcnt + 2)
Range("C" & condcnt).Value = Range("C" & condcnt + 2)
Else: Range("E" & condcnt).Value = Range("D" & condcnt).Value
End If
condcnt = condcnt + 1
Loop