Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you!!!!!
"Dave Peterson" wrote: Drop the .column at the end of this line: Set FoundCell = .Find(What:="Porter, Kevin", After:=.Cells(.Columns.Count), _ SearchOrder:=xlByRows).Column Set FoundCell = .Find(What:="Porter, Kevin", After:=.Cells(.Columns.Count), _ SearchOrder:=xlByRows) Kevin Porter wrote: Thanks Dave. I changed this to more closely do what I want. If FoundCell Is Nothing Then Exit Sub Else ColToFind = FoundCell.Column End If However, when I run the code I get this error: Run-time error '91': Object variable or With block not set When I hit debug it highlights Set FoundCell = .Find(What:="Porter, Kevin", After:=.Cells(.Columns.Count), _ SearchOrder:=xlByRows).Column ANy ideas why? "Dave Peterson" wrote: 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 -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I test for nulls within a range without specifying each ce | Excel Discussion (Misc queries) | |||
replace zeros with nulls | Excel Discussion (Misc queries) | |||
replace zeros with nulls | Excel Discussion (Misc queries) | |||
deaking with nulls, I think... | Excel Programming | |||
Excel has a "Find Next" command but no "Find Previous" command. | Excel Discussion (Misc queries) |