LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Alan
 
Posts: n/a
Default

Hello,

Thanks again.
I can now go off and do something else within the script if nothing is found
"FSt1" wrote:

hi,
if nothing was found, how do you trap nothing?
add this to the code before the other msgboxes.

If rng Is Nothing Then
MsgBox rn & " was Not found."
exit sub
End If

regards
FSt1


"Alan" wrote:

I use the code below to store a row number to a variable after a find.

I would like to trap a NO FIND if the find is unsuccessfull
Any ideas. FSt1 provided the code below

Sub macfindrow()
dim rn as string
dim rng as range
dim therow as long

rn = inputbox("enter something to find")
if rn < "" then
Set rng = nothing
Set rng = range("A1:IV65536").Find(what:=rn, _
After:=Range("A1"), _
Lookin:=xlformulas, _
Lookat:=xlpart, _
SearchOrder:=xlbyrows, _
SearchDirection:=xlNext, _
MatchCase:=false)
end if
therow = rng.row
msgbox "Found at cell " & rng.address
msbbox "The row number is " & therow
end sub


 
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
Find last occurance of text in range farutherford Excel Worksheet Functions 5 August 30th 05 02:00 AM
Find within Workbook. Matt Carter Excel Discussion (Misc queries) 2 August 3rd 05 07:40 PM
How do I find the cell address of the 2nd largest of a set? Mr. Snrub Excel Discussion (Misc queries) 4 May 30th 05 12:53 PM
Using the Find tool in EXCEL TK Excel Worksheet Functions 2 February 11th 05 07:51 PM
Excel has a "Find Next" command but no "Find Previous" command. Michael Fitzpatrick Excel Discussion (Misc queries) 2 January 10th 05 11:45 PM


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