Como reducir esta macro extensa
Quisiera saber si esta macro se puede reducir de algún forma, ya que la tengo que ejecutar dos veces y la segunda vez lo hace 10 veces más lento, dejo los primeros 3 rangos que me calculan la distancia entre puntos cardinales y me calcula cual es el siguiente punto más cercano.
Sub hasta70()
Range("J3").Select
ActiveCell.FormulaR1C1 = "=SQRT((R2C8-RC[-2])^2+(R2C9-RC[-1])^2)"
Range("J3").Select
Selection.AutoFill Destination:=Range("J3:J500")
Range("J3:J500").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("3:500").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Hoja1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Hoja1").Sort.SortFields.Add Key:=Range("J3:J500"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Hoja1").Sort
.SetRange Range("A3:O500")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("J4").Select
ActiveCell.FormulaR1C1 = "=SQRT((R3C8-RC[-2])^2+(R3C9-RC[-1])^2)"
Range("J4").Select
Selection.AutoFill Destination:=Range("J4:J500")
Range("J4:J500").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("4:500").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Hoja1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Hoja1").Sort.SortFields.Add Key:=Range("J4:J500"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Hoja1").Sort
.SetRange Range("A4:O500")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("J5").Select
ActiveCell.FormulaR1C1 = "=SQRT((R4C8-RC[-2])^2+(R4C9-RC[-1])^2)"
Range("J5").Select
Selection.AutoFill Destination:=Range("J5:J500")
Range("J5:J500").Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Rows("5:500").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Hoja1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Hoja1").Sort.SortFields.Add Key:=Range("J5:J500"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Hoja1").Sort
.SetRange Range("A5:O500")
.Header = xlGuess
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With