Private Function FindPos(intColumn As Integer, strContent As String) As Integer Dim i As Integer i = 1 Do While i < 30000 If CStr(ThisWorkbook.ActiveSheet.Cells(i, intColumn)) = strContent Then FindPos = i Exit Do End If i = i + 1 LoopEnd FunctionPublic Sub s() MsgBox FindPos(1, "a") End Sub
Private Function FindPos(intColumn As Long, strContent As String) As Integer Dim i As long i = 1 Do While i < 200000'这下满足了吧 If CStr(ThisWorkbook.ActiveSheet.Cells(i, intColumn)) = strContent Then FindPos = i Exit Do End If i = i + 1 LoopEnd FunctionPublic Sub s() MsgBox FindPos(1, "a")'1是第一列,a是特定数据 End Sub
Dim i As Integer
i = 1
Do While i < 30000
If CStr(ThisWorkbook.ActiveSheet.Cells(i, intColumn)) = strContent Then
FindPos = i
Exit Do
End If
i = i + 1
LoopEnd FunctionPublic Sub s()
MsgBox FindPos(1, "a")
End Sub
Dim i As long
i = 1
Do While i < 200000'这下满足了吧
If CStr(ThisWorkbook.ActiveSheet.Cells(i, intColumn)) = strContent Then
FindPos = i
Exit Do
End If
i = i + 1
LoopEnd FunctionPublic Sub s()
MsgBox FindPos(1, "a")'1是第一列,a是特定数据
End Sub
找文字
Range("C1").Select
ActiveCell.FormulaR1C1 = "=MATCH(""要找的字符串"",C[2],0)"
Debug.Print "单元格位置:"; ActiveCell.Value
找数字
Range("C1").Select
ActiveCell.FormulaR1C1 = "=MATCH(9,C[2],0)"
Debug.Print "单元格位置:"; ActiveCell.Value