AK_Beaver
03-09-2017, 05:16 PM
I'm trying to write a VBA code that calculates mean bearing of a group of bearings and distances. The Input needs to be a Range.
Bearing
Distance
N 80-05-36 E
664.62
S 88-58-12 E
2640.00
S 88-58-12 E
2517.90
I already have a code that converts the bearings to Azimuths in decimal degrees (i.e. N 88-00-00 E = 88.00000) and I get the overall idea of what I need to do. Each Bearing needs to be multiplied by the distance and this is done for each row. Those are added together and then divided by the sum of all the distances. My question is...Is their a way to write the code so that I don't need to call a specific cell for the calculations. For example: I don't want to have to say like
((A1*A2)+(B1*B2))/(B1+B2). I'm hoping to be able to write out the bearings and distances in any two columns on my sheet, input the range into the function and have the mean bearing output be calculated. If you can help steer me in the right direction, I'd appreciate it.
Bearing
Distance
N 80-05-36 E
664.62
S 88-58-12 E
2640.00
S 88-58-12 E
2517.90
I already have a code that converts the bearings to Azimuths in decimal degrees (i.e. N 88-00-00 E = 88.00000) and I get the overall idea of what I need to do. Each Bearing needs to be multiplied by the distance and this is done for each row. Those are added together and then divided by the sum of all the distances. My question is...Is their a way to write the code so that I don't need to call a specific cell for the calculations. For example: I don't want to have to say like
((A1*A2)+(B1*B2))/(B1+B2). I'm hoping to be able to write out the bearings and distances in any two columns on my sheet, input the range into the function and have the mean bearing output be calculated. If you can help steer me in the right direction, I'd appreciate it.