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
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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)
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top