Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default help with 'Find' error handling please

Hi All,

The code pasted below loops thru a list, finds that value in a list on
another sheet and deletes the entire row. I need to put an error
handler in so that if the value is not found a msg box pops up to
inform the user then continues the loop

All help gratefully received.

Dim delName As String
Dim lr As Long
Dim ur
Sheets("TemporaryList").Activate
Range("A1").Activate
ur = Range(Selection, Selection.End(xlDown)).Address
Range(ur).AdvancedFilter Action:=xlFilterInPlace,
CopyToRange:=Columns( _
"E:E"), Unique:=True
Range("A2").Activate
Do Until ActiveCell.Value = ""
Sheets("TemporaryList").Activate
delName = ActiveCell.Value
Sheets("Current").Activate
With Worksheets("Current").Range("A:A")
Set c = .Find(delName, lookin:=xlValues)
c.EntireRow.Delete
End With
Sheets("TemporaryList").Activate
ActiveCell.Offset(1, 0).Activate
Loop
MsgBox ("finished")
Regards

Michael Beckinsale

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default help with 'Find' error handling please

With Worksheets("Current").Range("A:A")
Set c = .Find(delName, lookin:=xlValues)
if c is Nothing then
MsgBox "Search Value was not found"
else
c.EntireRow.Delete
End if
End With

HTH

Die_Another_Day
michael.beckinsale wrote:
Hi All,

The code pasted below loops thru a list, finds that value in a list on
another sheet and deletes the entire row. I need to put an error
handler in so that if the value is not found a msg box pops up to
inform the user then continues the loop

All help gratefully received.

Dim delName As String
Dim lr As Long
Dim ur
Sheets("TemporaryList").Activate
Range("A1").Activate
ur = Range(Selection, Selection.End(xlDown)).Address
Range(ur).AdvancedFilter Action:=xlFilterInPlace,
CopyToRange:=Columns( _
"E:E"), Unique:=True
Range("A2").Activate
Do Until ActiveCell.Value = ""
Sheets("TemporaryList").Activate
delName = ActiveCell.Value
Sheets("Current").Activate
With Worksheets("Current").Range("A:A")
Set c = .Find(delName, lookin:=xlValues)
c.EntireRow.Delete
End With
Sheets("TemporaryList").Activate
ActiveCell.Offset(1, 0).Activate
Loop
MsgBox ("finished")
Regards

Michael Beckinsale


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 274
Default help with 'Find' error handling please


Hi Die_Another_Day

Many thanks.

Reagrds

Michael beckinsale

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
UDF Error Handling is ignored. Not for everyone? [email protected] Excel Programming 4 March 22nd 06 06:31 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Error handling with a handling routine ben Excel Programming 0 March 15th 05 03:01 PM
Error Handling James Agostinho Excel Programming 1 January 30th 04 06:40 AM
Error handling John Pierce Excel Programming 3 October 3rd 03 12:17 PM


All times are GMT +1. The time now is 03:09 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"