Thread: VBA Problem
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Melanie Breden Melanie Breden is offline
external usenet poster
 
Posts: 88
Default VBA Problem

Hi Tom,

TomD wrote:
I have this code as part of a "Show Winners" macro
button..........

Cells.Find(What:="Ladies", After:=ActiveCell,
LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

Which, if Ladies not found (because button activated
without any entries being made in spreadsheet), gives....

Runtime error 91
Object variable or With Block varibale not set.


try this:

Dim rngFind As Range

Set rngFind = _
Cells.Find(What:="Ladies", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)

If Not rngFind Is Nothing Then rngFind.Select

--
Mit freundlichen Grüssen

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)