PDA

View Full Version : Type mismatch error



satyen
03-24-2010, 07:59 AM
Hello,

I get a type mismatch error when writing this line of code. I'm doing something wrong and I can't figure it out. ! Please can someone point out my mistake. Thanks.

Range("A:A").Find(What:="My Tables", After:=ActiveCell, LookIn:=xlFormulas _
, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Select

austenr
03-24-2010, 09:30 AM
Might need a little more info.

austenr
03-24-2010, 09:35 AM
Seems like if you put "My Tables" in a cell in column A it clears it up. Did at least for me. Using the quotes around the string made the error go away.

Paul_Hossler
03-24-2010, 10:08 AM
It only works if the ActiveCell is in Col A. I think it was the After:=ActiveCell

If "My Tables" is not found, then you'll get an error when you try to select it


Sub drv()
Dim r As Range
Set r = Range("A:A").Find(What:="My Tables", LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not r Is Nothing Then r.Select
Set r = Range("A:A").Find(What:="Not There", LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not r Is Nothing Then r.Select

End Sub


Paul