View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default selection.find help!

Is Interiminput the codename of a sheet.

Do you want to search on multiple sheets

Dim sVal as String, sh as Worksheet
Dim rng as Range
sVal = Interiminput.regint.Value
for each sh in thisworkbook.worksheets
sh.Activate
set rng = sh.Cells.Find(What:=sVal, _
LookIn:=xlValues, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
if not rng is nothing then
rng.Select
MsgBox "Found!"
exit sub
end if
Next
if rng is nothing then
msgbox sVal & " was not found"
end if

--
Regards,
Tom Ogilvy


"Duncan" wrote in message
oups.com...
Hi all,

My code used to work when i only had one sheet in the workbook, it done
Selection.Find(What:=Interiminput.regint.Value, LookIn:=xlValues,
SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False).Activate

now that i have added more sheets it comes up with "object variable or
with block variable not set" when it gets to the code.

This must be real simple but I am banging my head against the wall!

any ideas?

Duncan