View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default how do i use find in VB

Sub Button1_Click()
Dim sh as Worksheet
Dim rng as Range
Dim s as String
s = "*"
for each sh in worksheets
set rng = sh.Cells.Find(What:=s, _
After:=sh.Range("IV65536"), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext,
MatchCase:=False)
if not rng is nothing then
application.Goto rng, true
msgbox "Found at: " & rng.Address(0,0,xlA1,true)
end if
Next
End sub



--
Regards,
Tom Ogilvy





"tofy" wrote:

Dear sir,
I am trying to use VB to find data, not in the same worksheet but in whole
workbook.
I programed in VB as the following:

Sub Button1_Click()
Cells.Find(What:="", After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False _
, SearchFormat:=False).Activate

End Sub

Well, it works to find data at the active worksheet but I need to find data
at different worksheets(all workbook) I tried to use
Xlsearchwithin.Xlwithinworkbook
but it keeps giveing an error.
Please could you help me.
Yours
Taufik