Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Capturing Row of Selection.Find?

Gang -

How do I capture the row of a successful Selection.Find?

I did find out that Selection.Find returns -1. What's that mean?

And how would I do this without making a selection? The macro recorder
doesn't help there. I ended up using a "For each cell" loop looking for
an equality and incrementing/capturing a counter.


Thanks in advance.

....best, Michael
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Capturing Row of Selection.Find?

rowno = Selection.Find("123").Row

I posted this to a previous posting from you!

" wrote:

Gang -

How do I capture the row of a successful Selection.Find?

I did find out that Selection.Find returns -1. What's that mean?

And how would I do this without making a selection? The macro recorder
doesn't help there. I ended up using a "For each cell" loop looking for
an equality and incrementing/capturing a counter.


Thanks in advance.

....best, Michael

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Capturing Row of Selection.Find?

...... by mistake! My fault!

" wrote:

Gang -

How do I capture the row of a successful Selection.Find?

I did find out that Selection.Find returns -1. What's that mean?

And how would I do this without making a selection? The macro recorder
doesn't help there. I ended up using a "For each cell" loop looking for
an equality and incrementing/capturing a counter.


Thanks in advance.

....best, Michael

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Capturing Row of Selection.Find?

Using Toppers approach is fine if you are guaranteed that the target value
will be found. If not, it is better to set a reference to the result of the
find command and then test if Find was successful

Dim rng as Range
set rng = Columns("C").Find("123")
if not rng is nothing then
rw = rng.row
Else
msgbox "123 not found"
exit sub
End if

--
Regards,
Tom Ogilvy


wrote in message news:w8rAf.9318$bF.2432@dukeread07...
Gang -

How do I capture the row of a successful Selection.Find?

I did find out that Selection.Find returns -1. What's that mean?

And how would I do this without making a selection? The macro recorder
doesn't help there. I ended up using a "For each cell" loop looking for
an equality and incrementing/capturing a counter.


Thanks in advance.

...best, Michael



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Capturing Row of Selection.Find?

Tom -

Thank you. Toppers message never made it to my news server, but I see
the way to go.

Thanks again.
....Hash

In article ,
"Tom Ogilvy" wrote:

Using Toppers approach is fine if you are guaranteed that the target value
will be found. If not, it is better to set a reference to the result of the
find command and then test if Find was successful

Dim rng as Range
set rng = Columns("C").Find("123")
if not rng is nothing then
rw = rng.row
Else
msgbox "123 not found"
exit sub
End if



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 can I find the series selection tab? Kat @ Rose Valley Charts and Charting in Excel 1 October 6th 09 06:04 PM
selection.find help! Duncan[_5_] Excel Programming 7 January 18th 06 09:07 AM
Capturing the column number and # of columns in a selection Ralph Heidecke[_2_] Excel Programming 2 March 18th 05 06:27 PM
Find selection C3 Excel Programming 1 April 5th 04 12:37 PM
Find the row of all cells in a selection TonyJeffs Excel Programming 1 September 1st 03 05:05 PM


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