Object syntax with a Period ( . )
workbooks("a.xls").Worksheets(1).Range("A1:Z26").F ind
What:=workbooks("a.xls").Worksheets(1).Range("M1") ,
After:=workbooks("a.xls").Worksheets(1).Range("Z26 ")
It a complete qualification of a range used to be searched by the find
command. For convenience you can use the with statement
workbooks("a.xls").Worksheets(1)
..Range("A1:Z26").Find what:=.Range("M1"), _
After:=Range("Z26")
End With
each reference that has a leading period is referring back to the with
statement. There is nothing unique to the Find command and using a leading
period.
--
Regards,
Tom Ogilvy
"Neal Zimm" wrote:
I took the code below from the VBA help example for the
Find Next method, and am in process of learning more
about it and building a general find proc that can be called.
In this line,
Set InfoCell = .Find(IFindThis, LookIn:=xlFormulas)
I remember reading somewhere about the period(.) being
placed before the word Find. Not that I'm looking for that
documentation, I can't find it. (no pun intended)
Can someone point me to the right section and/or give me
a brief explanation of the .Find syntax?
thanks,
Neal Z
Sub zzz_Find_Method(IFindThis)
'This example finds all cells in the range A1:A25 that _
contain the value in the IFindThis var.
Dim InfoCell As Object
Dim FirstAddress
'With Worksheets("2222-0900").Range("a1:a25")
With Worksheets("2222-0900").Range(Cells(1, 1), Cells(25, 1))
Set InfoCell = .Find(IFindThis, LookIn:=xlFormulas)
If Not InfoCell Is Nothing Then
FirstAddress = InfoCell.Address
MsgBox "FirstAddress= " & FirstAddress & Cr _
& "InfoCell.Row= " & InfoCell.Row & " InfoCell.Column= " &
InfoCell.Column
Do
Set InfoCell = .FindNext(InfoCell)
If Not InfoCell Is Nothing And InfoCell.Address < FirstAddress _
Then MsgBox InfoCell.Address
Loop Until Not InfoCell Is Nothing And InfoCell.Address = FirstAddress
Else
MsgBox IFindThis & " is NOT found."
End If
End With
End Sub
--
Neal Z
|