|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
玫瑰蝴蝶雨 发表于 2012-9-15 06:09 ![](static/image/common/back.gif)
感谢您这么晚还来解决我的问题,我下载后到其他数据中试一下,真的很感激您,谢谢
另外有一点您看能否解 ...
vba:
Sub t()
Dim i, a, b, k As Integer
Dim L() As Long
k = Range("L65536").End(xlUp).Row
ReDim L(k)
For i = 2 To k
If Cells(i, 19) = "" Then
For a = 2 To k
L(a) = Abs(Cells(i, 12) - Cells(a, 12)) + Abs(Cells(i, 13) - Cells(a, 13))
If Cells(a, 19) = "" Then
L(a) = 11111
End If
Next
b = Application.Match(Application.WorksheetFunction.Min(L), L, 0)
Cells(i, 19) = Cells(b + 1, 19)
End If
Next
End Sub
|
|