Hi,
I am trying to calculate the 3D distance between the cells in range A1:V3579 and those in X1:AS4860.
For each row in the first range, calculate the distance between that and all points in the second range, I find the minimum of all the data in AT and copy that row in the range to a separate sheet- I go down each row in the first range and compare with all cells in AT to find the minimum and past beneath the prior minimum in the new sheet.
The macro i developed however...does not work.
Any help on this will be appreciated.
I am trying to calculate the 3D distance between the cells in range A1:V3579 and those in X1:AS4860.
For each row in the first range, calculate the distance between that and all points in the second range, I find the minimum of all the data in AT and copy that row in the range to a separate sheet- I go down each row in the first range and compare with all cells in AT to find the minimum and past beneath the prior minimum in the new sheet.
The macro i developed however...does not work.
Code:
Sub Macro2()
'
' Macro2 Macro
'
'
Range("AT2").Select
For I = 1 To 3578
ActiveCell.FormulaR1C1 = _
"=((((R[I+1]C[-44]-RC[-21])^2)+((R[I+1]C[-32]-RC[-9])^2)+((R[I+1]C[-31]-RC[-8])^2))^0.5)"
Selection.AutoFill Destination:=Range("AT2:AT4860")
Range("AT2:AT4860").Select
Range("AU2").Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]=MIN(RC[-1]:R[4858]C[-1]),1,0)"
Range("AU2").Select
Selection.AutoFill Destination:=Range("AU2:AU4860")
Range("AU2:AU4860").Select
Range("A22:AU22").Select
Range("AU22").Activate
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Next I
End Sub
Any help on this will be appreciated.
Last edited by a moderator: