Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Stopping errors when a find statement doesn't find!


Hi there,
I have the following code that assumes the value it is looking for is
always present:


Code:
--------------------

Range(Columns("A:A").Find("Unplanned Prospects").Offset(0, 0), _
Columns("A:A").Find("Unplanned Prospects Total").Offset(0, 14)).Select
Selection.borders(xlDiagonalDown).LineStyle = xlNone
Selection.borders(xlDiagonalUp).LineStyle = xlNone
Code:
--------------------


i've just run this and it couldn't find "Unplanned Prospects" so it returned an error.
how can I get around this?

thanks in advance,
Matt


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=504857

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Stopping errors when a find statement doesn't find!

Hi Matt

See if this makes sense:

Sub test()
Dim Found As Range
On Error Resume Next
Set Found = Columns("A:A").Find("Unplanned Prospects")
If Found Is Nothing Then
MsgBox "No such thing"
Else
MsgBox Found.Address
End If
End Sub


HTH. Best wishes Harald

"matpj" skrev i melding
...

Hi there,
I have the following code that assumes the value it is looking for is
always present:


Code:
--------------------

Range(Columns("A:A").Find("Unplanned Prospects").Offset(0, 0), _
Columns("A:A").Find("Unplanned Prospects Total").Offset(0, 14)).Select
Selection.borders(xlDiagonalDown).LineStyle = xlNone
Selection.borders(xlDiagonalUp).LineStyle = xlNone
Code:
--------------------


i've just run this and it couldn't find "Unplanned Prospects" so it

returned an error.
how can I get around this?

thanks in advance,
Matt


--
matpj
------------------------------------------------------------------------
matpj's Profile:

http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=504857



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Stopping errors when a find statement doesn't find!

Dim rng as Range
set rng = Columns("A:A").Find("Unplanned Prospects")
if not rng is nothing then
With rng.Resize(1,15)
.borders(xlDiagonalDown).LineStyle = xlNone
.borders(xlDiagonalUp).LineStyle = xlNone
end With
Else
msgbox "Not found"
End If

--
Regards,
Tom Ogilvy


"matpj" wrote in
message ...

Hi there,
I have the following code that assumes the value it is looking for is
always present:


Code:
--------------------

Range(Columns("A:A").Find("Unplanned Prospects").Offset(0, 0), _
Columns("A:A").Find("Unplanned Prospects Total").Offset(0, 14)).Select
Selection.borders(xlDiagonalDown).LineStyle = xlNone
Selection.borders(xlDiagonalUp).LineStyle = xlNone
Code:
--------------------


i've just run this and it couldn't find "Unplanned Prospects" so it

returned an error.
how can I get around this?

thanks in advance,
Matt


--
matpj
------------------------------------------------------------------------
matpj's Profile:

http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=504857



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Stopping errors when a find statement doesn't find!


thanks guys, thats great.

I have it working now!! :)


--
matpj
------------------------------------------------------------------------
matpj's Profile: http://www.excelforum.com/member.php...o&userid=21076
View this thread: http://www.excelforum.com/showthread...hreadid=504857

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
cells.find & stopping the search michaelberrier Excel Discussion (Misc queries) 5 May 13th 06 08:32 PM
To find errors Kalevi New Users to Excel 1 October 14th 05 03:43 PM
VBA- Find Errors jordanctc[_17_] Excel Programming 2 September 10th 04 03:45 AM
Find errors John Excel Programming 2 December 31st 03 04:28 PM
Find finds nothing, and errors Chris M.[_3_] Excel Programming 1 August 25th 03 06:31 PM


All times are GMT +1. The time now is 05:15 PM.

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

About Us

"It's about Microsoft Excel"