VBA Coding Query/ideas

akjohno

New Member
Joined
Mar 27, 2018
Messages
27
Office Version
  1. 365
Platform
  1. Windows
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):confused: 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
 

Some videos you may like

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

akjohno

New Member
Joined
Mar 27, 2018
Messages
27
Office Version
  1. 365
Platform
  1. Windows
oh i should have said the columns are A - x co-ordinate, B - y co-ordinate, C - z value, D - feature code (descriptor of what the survey shot was of)
 

Watch MrExcel Video

Forum statistics

Threads
1,109,115
Messages
5,526,918
Members
409,729
Latest member
Darren S

This Week's Hot Topics

Top