Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Find finds nothing, and errors

I have a Selection.find function that errors out if it
does not find the value. I'd like to make it skip this
section if it does not find anything. Here's my code:

Private Sub Findtotal()
Dim Cell As Range, LastCell As String
Application.ScreenUpdating = False
Columns("A:A").Select
Selection.Find(What:="Fees", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Activate
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(1,
0).End(xlDown)).Select
For Each Cell In Selection
If Not IsEmpty(Cell) Then Cell = Cell & " FEES"
Next

I'm not exactly sure how to make it work correctly wether
or not it finds anything. Thanks in advance for any help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Find finds nothing, and errors

you get an error if nothing is found because of the activate on the end of
the find command - you can't activate Nothing.

Private Sub Findtotal()
Dim rng as Range
Dim Cell As Range, LastCell As String
Application.ScreenUpdating = False
Columns("A:A").Select
set rng = Selection.Find(What:="Fees", After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
if not rng is nothing then
rng.Select
Range(ActiveCell.Offset(1, 0), _
ActiveCell.Offset(1,0).End(xlDown)).Select
For Each Cell In Selection
If Not IsEmpty(Cell) Then Cell = Cell & " FEES"
Next
end if

--
Regards,
Tom Ogilvy


"Chris M." wrote in message
...
I have a Selection.find function that errors out if it
does not find the value. I'd like to make it skip this
section if it does not find anything. Here's my code:

Private Sub Findtotal()
Dim Cell As Range, LastCell As String
Application.ScreenUpdating = False
Columns("A:A").Select
Selection.Find(What:="Fees", After:=ActiveCell,
LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext, _
MatchCase:=False).Activate
Range(ActiveCell.Offset(1, 0), ActiveCell.Offset(1,
0).End(xlDown)).Select
For Each Cell In Selection
If Not IsEmpty(Cell) Then Cell = Cell & " FEES"
Next

I'm not exactly sure how to make it work correctly wether
or not it finds anything. Thanks in advance for any help.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find errors in documents Pnoahjones Excel Discussion (Misc queries) 1 March 25th 10 04:29 AM
Find and Replace Lookup errors Julie Excel Discussion (Misc queries) 7 July 13th 07 09:36 PM
Excel Throwing Circular Errors When No Errors Exist MDW Excel Worksheet Functions 1 August 10th 06 02:15 PM
To find errors Kalevi New Users to Excel 1 October 14th 05 03:43 PM
Unresolved Errors in IF Statements - Errors do not show in results Markthepain Excel Worksheet Functions 2 December 3rd 04 08:49 AM


All times are GMT +1. The time now is 12:47 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"