View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Nulls within a .Find command

Dim FoundCell as Range
dim ColToFind as long

With Workbooks("Workbookname.xls").Sheets("Total").Rows (1)
set foundcell = .Find(What:="What I am looking for", _
After:=.Cells(.Columns.Count), SearchOrder:=xlByRows)
end with

if foundcell is nothing then
Coltofind = 99999 'what do you want?
else
coltofind = foundcell.column
end if


Kevin Porter wrote:

Here is the code:

With Workbooks("Workbookname.xls").Sheets("Total").Rows (1)

ColToFind = .Find(What:="What I am looking for",
After:=.Cells(.Columns.Count), _
SearchOrder:=xlByRows).Column

End With

The problem is sometimes ColToFind is not going to be there. I need a way
to tell it that if ColToFind comes back null then do not continue the module.


--

Dave Peterson