|
楼主 |
发表于 2018-8-7 11:40
|
显示全部楼层
非常感谢各位高手,小弟也是初期琢磨中,经过一提醒茅塞顿开。下面我修改了下,烦请各位再给看看,还是有错误提示:错误13,类型不匹配。 大概有5万多行。
Option Explicit
Sub test()
Dim i&, n&, r, Arr, arr1
Application.ScreenUpdating = False
r = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
Sheets("Sheet1").Range("H2:H" & r).ClearContents
Arr = Sheets("Sheet1").Range("e2:f" & r)
ReDim arr1(1 To UBound(Arr), 1 To 1)
r = r - 1
For i = 1 To r
n = i
arr1(n, 1) = jl(Range("J1"), Range("K1"), Arr(i, 1), Arr(i, 2))
If arr1(n, 1) >= 300 Then
arr1(n, 1) = ""
Else
[H2].Resize(UBound(Arr), 1) = arr1
End If
Next i
Application.ScreenUpdating = True
End Sub
Function jl(x1, y1, x2, y2)
jl = 6378137 * 2 * Application.Asin(Sqr(Application.SumSq(Sin((Application.Radians(y1) - Application.Radians(y2)) / 2)) + Cos(Application.Radians(y1)) * Cos(Application.Radians(y2)) * Application.SumSq(Sin((Application.Radians(x1) - Application.Radians(x2)) / 2))))
End Function |
|