本帖最后由 gto250 于 2011-5-27 22:32 编辑
excel vba中的find在au3中该如何使用?Sub Macro1()
Dim RNG As Range
Dim FirstAddress As String
Dim FindAddress As String
With Sheet1
Set RNG = .Range("A1:w66").Find(what:=5, after:=.Range("A1"), LookIn:=xlValues, lookat:=xlWhole)
If Not (RNG Is Nothing) Then
FirstAddress = RNG.Address
Do
FindAddress = FindAddress & RNG.Address & vbCrLf
Set RNG = .Range("A1:w66").FindNext(RNG)
Loop Until RNG.Address = FirstAddress
End If
MsgBox "查找结果是:" & vbCrLf & FindAddress
End With
End Sub
上面是使用的find的例子
我用au3改了个相视的,不过查找的是颜色格式的单元格
#include <Excel.au3>
Dim $FirstAddress,$FindAddress
$myex = ObjGet("","excel.Application")
$myex.findformat.Interior.ColorIndex = 6
With $myex.activesheet
$RNG = .Range("A1:w66").Find("", .ActiveCell, $xlValue, $xlPart, $xlByRows, $xlNext, False,False,True)
If $RNG="" Then
$FirstAddress = $RNG.Address
Do
$FindAddress = $FindAddress & $RNG.Address & @CrLf
$RNG = .Range("A1:w66").FindNext($RNG)
Until $RNG.Address = $FirstAddress
EndIf
MsgBox(0,"", "查找结果是:" & $FindAddress)
EndWith
卡在这句上有错误,不知道是什么错误,该怎么改? |