excel中vba问题
SubRngFindNext()DimStrFindAsStringDimRngAsRangeDimFindAddressAsStringStrFind=InputBox...
Sub RngFindNext()
Dim StrFind As String
Dim Rng As Range
Dim FindAddress As String
StrFind = InputBox("请输入要查找的值:")
If Trim(StrFind) <> "" Then
With Sheet1.Range("A:A")
Set Rng = Sheet1.Range("A:A").Find(StrFind, .Cells(.Cells.Count, 1), xlValues, xlWhole, xlByRows, xlNext, False)
If Not Rng Is Nothing Then
FindAddress = Rng.Address
Do
Rng.Interior.ColorIndex = 6
Set Rng = Sheet1.Range("A:A").FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address <> FindAddress
End If
End With
End If
End Sub
大哥,在这个问题中我有几个问题想问,一个是trim()是什么作用,另外rng.address<>findaddress,怎么理解这个不等于,谢谢 展开
Dim StrFind As String
Dim Rng As Range
Dim FindAddress As String
StrFind = InputBox("请输入要查找的值:")
If Trim(StrFind) <> "" Then
With Sheet1.Range("A:A")
Set Rng = Sheet1.Range("A:A").Find(StrFind, .Cells(.Cells.Count, 1), xlValues, xlWhole, xlByRows, xlNext, False)
If Not Rng Is Nothing Then
FindAddress = Rng.Address
Do
Rng.Interior.ColorIndex = 6
Set Rng = Sheet1.Range("A:A").FindNext(Rng)
Loop While Not Rng Is Nothing And Rng.Address <> FindAddress
End If
End With
End If
End Sub
大哥,在这个问题中我有几个问题想问,一个是trim()是什么作用,另外rng.address<>findaddress,怎么理解这个不等于,谢谢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询