|
楼主 |
发表于 2013-11-1 19:51
|
显示全部楼层
本帖最后由 ebbe 于 2013-11-1 20:17 编辑
那么的帅 发表于 2013-11-1 11:28
已解决
太牛逼了,终于搞定了。非常感谢。但是原理不是很明白
我把代码贴出来吧。
Function DTime(查找值 As Range, 查找范围, 查找列数 As Integer, 返回列数 As Integer)
On Error Resume Next
add1 = 查找范围.Address
If InStr(add1, "[") = 0 Then
arr = 查找范围
LastRow = UBound(arr)
For i = 1 To LastRow
If 查找值 = arr(i, 查找列数) Then
result = arr(i, 返回列数)
Exit For
End If
Next i
DTime = result
Else
LastRow = UBound(查找范围)
For i = 1 To LastRow
If 查找值 = 查找范围(i, 查找列数) Then
result = 查找范围(i, 返回列数)
Exit For
End If
Next i
DTime = result
End If
End Function
为什么 add1 = 查找范围.Address
If InStr(add1, "[") = 0 Then
一个用数组,另一个却不用数组就解决问题了呢?主要是红色部分不理解
|
|