Method or data member not found

G

Guest

Why do i get this error
Thank You
Esau

Sub aaa()
'
Dim rng As Range, sh As Worksheet
WhatToFind = ActiveCell.Value
For Each sh In
Workbooks.Worksheets 'Highlights .W
orksheets Error Method or Data member not found
sh.Activate
Set rng = Cells.Find(What:=WhatToFind, _
After:=Range("IV65536"), _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not rng Is Nothing Then
rng.Select
ans = MsgBox("continue searching? ", vbYesNo)
If ans = vbNo Then Exit Sub
End If
Next
End Sub
 
S

SOS

Hi Esau,

change the line in your code from

For Each sh In *Workbook*.Worksheets

to

For Each sh In *ActiveWorkbook*.Worksheets

and it should work

Regards

Seamu
 

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

Top