Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I keep getting type mismatch error!

Status
Not open for further replies.

minibebe

Programmer
May 1, 2007
3
GB
I have the following code, trying to locate the same symbol in the range named newvar as the range i'm working with now. But even though I can find the symbol using Ctrl+F, the following code keeps giving me type mismatch error. Can someone help? Thanks!

Set newvar = Range(Cells(3, 1), Cells(65536,5))

begr = 3
endr = [h65536].End(xlUp).Row

Do While begr <= endr
If Application.CountIf(newvar, Cells(begr, 8)) <> 0 Then
CGSYM = Cells(begr, 8)
newvar.Find(What:=CGSYM, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Select


End If
begr = begr + 1
Loop
 
Depends on where your error is occurring.
Application.CountIf(newvar, Cells(begr, 8)) <> 0 Then isn't how I'm familiar with CountIf: countif(range, criteria). That is, the range you supply, newvar isn't involved in the criterion.

_________________
Bob Rashkin
 
Hi Bob,

Thanks for your help. The error's occuring at the following section:

newvar.Find(What:=CGSYM, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False).Select

Thanks!
 
what happens if you use: lookin:=xlValues?
Better yet, leave off all the optional parameters:
newvar.Find(What:=CGSYM)


_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top