Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Find / FindNext Methods

When using the Find / FindNext methods, they return the address of the value
that is being searched for (if found). Is it possible to extract the row
information from that address?

For example, let's say that in a spreadsheet, column A contains zip codes
and column G contains names. You need to come up with a listing of all the
names for zip code 12345. When you run the search, the address returned by
Find references the zip code found in column A, but you really need to get
the corresponding name out of column G. If you could get the row from each
address, and since the names are in column G, you could then pull the value
from that cell.

I haven't run across anything similar to this problem explained, and am not
sure it can be done. My last resort would be to do a line-by-line search,
but that isn't the most efficient way to search. Any ideas would be
appreciated.
--
Thanks,
Paul S
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Find / FindNext Methods

Simplified pseudo code

Dim rng as Range
Dim rng1 as Range
Dim sAddr as String
With worksheets("Sheet1")
set rng = .range(.cells(2,1),.cells(rows.count,1).End(xlup))
End with

set rng1 = rng.Find("22200", . . . )

if not rng1 is nothing then
sAddr = rng.Address
do
msgbox rng.Address & rng.offset(0,6).Address & vbNewline & _
rng.Value & ", " & rng.offset(0,6).Value
set rng1 = rng.FindNext(rng1)
Loop while rng1.Address < sAddr
End if

--
Regards,
Tom Ogilvy


"Paul S" wrote:

When using the Find / FindNext methods, they return the address of the value
that is being searched for (if found). Is it possible to extract the row
information from that address?

For example, let's say that in a spreadsheet, column A contains zip codes
and column G contains names. You need to come up with a listing of all the
names for zip code 12345. When you run the search, the address returned by
Find references the zip code found in column A, but you really need to get
the corresponding name out of column G. If you could get the row from each
address, and since the names are in column G, you could then pull the value
from that cell.

I haven't run across anything similar to this problem explained, and am not
sure it can be done. My last resort would be to do a line-by-line search,
but that isn't the most efficient way to search. Any ideas would be
appreciated.
--
Thanks,
Paul S

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Find / FindNext Methods

Thanks, Tom. I should be able to make the adjustments and get this snippet
to fit in nicely.
--
Thanks,
Paul S


"Tom Ogilvy" wrote:

Simplified pseudo code

Dim rng as Range
Dim rng1 as Range
Dim sAddr as String
With worksheets("Sheet1")
set rng = .range(.cells(2,1),.cells(rows.count,1).End(xlup))
End with

set rng1 = rng.Find("22200", . . . )

if not rng1 is nothing then
sAddr = rng.Address
do
msgbox rng.Address & rng.offset(0,6).Address & vbNewline & _
rng.Value & ", " & rng.offset(0,6).Value
set rng1 = rng.FindNext(rng1)
Loop while rng1.Address < sAddr
End if

--
Regards,
Tom Ogilvy


"Paul S" wrote:

When using the Find / FindNext methods, they return the address of the value
that is being searched for (if found). Is it possible to extract the row
information from that address?

For example, let's say that in a spreadsheet, column A contains zip codes
and column G contains names. You need to come up with a listing of all the
names for zip code 12345. When you run the search, the address returned by
Find references the zip code found in column A, but you really need to get
the corresponding name out of column G. If you could get the row from each
address, and since the names are in column G, you could then pull the value
from that cell.

I haven't run across anything similar to this problem explained, and am not
sure it can be done. My last resort would be to do a line-by-line search,
but that isn't the most efficient way to search. Any ideas would be
appreciated.
--
Thanks,
Paul S

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
Using Find & FindNext in a form BernzG[_13_] Excel Programming 3 August 19th 05 12:28 AM
Nesting Find and FindNext SA3214 Excel Programming 7 August 10th 05 08:23 PM
Using 'Find' and 'FindNext' in vba SA3214 Excel Programming 3 March 25th 05 12:17 PM
Find, Findnext VBA Loop SMS - John Howard Excel Programming 5 November 13th 04 03:19 AM


All times are GMT +1. The time now is 03:52 PM.

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"