|
楼主 |
发表于 2010-4-11 10:01
|
显示全部楼层
原帖由 skvin 于 2010-4-11 09:49 发表
请问罗老师,应该如何给FIND增加参数,最好上传附件,呵呵,我比较菜!
-
- Function look(查找值 As String, 区域 As Range, Optional 列 As Integer = 2, Optional 索引号 As Integer = 1) As String
- Application.Volatile
- Dim i As Long, cell As Range, Str As String
- With 区域(1).Resize(区域.Rows.Count, 1)
- If .Cells(1) = 查找值 Then Set cell = .Cells(1) Else Set cell = .Find(查找值, LookIn:=xlValues, Lookat:=xlWhole)
- If Not cell Is Nothing Then
- Str = cell.Address
- Do
- i = i + 1
- If i = 索引号 Then look = cell.Offset(0, 列 - 1): Exit Function
- Set cell = 区域.Find(查找值, cell, , xlWhole)
- Loop While Not cell Is Nothing And cell.Address <> Str
- End If
- End With
- End Function
复制代码 |
|