Find text string within a named range

A

AshMorK

Hi all,

I'm trying to find a text string using a named range as the searching area
but it doesn't work:

Sub names()
Dim RngToSearch As Name
Dim RngFound As Range
Set RngToSearch = ActiveWorkbook.names("tipos_dcto")

c = ActiveCell.Value

Set RngFound = RngToSearch.Find(c)

If RngFound Is Nothing Then
MsgBox "xxx"
Else

End If

End Sub

Any Ideas??

Thanks in advance.
 
B

Bob Phillips

Set RngToSearch = ActiveWorkbook.Range("tipos_dcto")


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
A

AshMorK

Thnks Bob x ur help. But although it makes reference to the named range, the
sub still can't find anything. And returns a "run time error '438': Objet
doesn't support this property or method".

Thanks.
 
P

Peter T

changeto
Dim RngToSearch As Range

and then try this
Set RngToSearch = ActiveWorkbook.names("tipos_dcto").RefersToRange
Set RngFound = RngToSearch.Find(c)

Regards,
Peter T
 
A

Andrew Taylor

ActiveWorkbook (and Workbook objects generally) don't have a Range
method. You need either to change it to
ActiveWorksheet.Range("tipos_dicto")
or to use Peter T's suggestion of
ActiveWorkbook.names("tipos_dcto").RefersToRange
 
A

AshMorK

Thanks Peter, It works perfectly now!!!

Peter T said:
change
to
Dim RngToSearch As Range

and then try this
Set RngToSearch = ActiveWorkbook.names("tipos_dcto").RefersToRange
Set RngFound = RngToSearch.Find(c)

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top