Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
BillCPA
 
Posts: n/a
Default Reverse MATCH Function

I have an array with 500+ elements. Assume elements 100, 200, 300, and 400
are equal to 'Sue'. For each occurrence of Sue, I want to find the row
number for the next occurrence and for the previous occurrence. At 100, I
get 200 and 'none'. At 200, I get 300 and 100. But when I get to 300, I get
400 and 100, altho I want 400 and 200. When I am at 300, is there some way
to have the search start at 299 and search backwards so that the first match
it comes to is at 200?

--
Bill @ UAMS
  #2   Report Post  
Myrna Larson
 
Posts: n/a
Default

Assuming the names in column A, in a column on the right, say K, put this
formula

=IF(A1="Sue",COUNTIF(A$1:A1,"Sue"),"")

and copy it down. With the example you give, the formula should return 3 at
row 300. Then you can use

=MATCH(K300-1,$K$!:$K$500,0)

to get the row above and

=MATCH(K300+1,$K$!:$K$500,0)

to get the row below.

Of course, if "Sue" is just an example, and you really want to search for
other names as well, this isn't going to work.

On Tue, 8 Mar 2005 14:29:06 -0800, "BillCPA" <Bill @ UAMS wrote:

I have an array with 500+ elements. Assume elements 100, 200, 300, and 400
are equal to 'Sue'. For each occurrence of Sue, I want to find the row
number for the next occurrence and for the previous occurrence. At 100, I
get 200 and 'none'. At 200, I get 300 and 100. But when I get to 300, I get
400 and 100, altho I want 400 and 200. When I am at 300, is there some way
to have the search start at 299 and search backwards so that the first match
it comes to is at 200?


  #3   Report Post  
Biff
 
Posts: n/a
Default

Hi!

Not pretty but it works!

I assume there are no blanks in the array and you want
this for each element. My tests were based on a range of
A1:A15. Adjust to suit. In B1 I array entered this formula
with the key combo of CTRL,SHIFT,Enter:

=IF(ISERROR(SMALL(IF(A$1:A$15=A1,ROW(A$1:A$15)),CO UNTIF
(A$1:A1,A1)+1)),"none",SMALL(IF(A$1:A$15=A1,ROW
(A$1:A$15)),COUNTIF(A$1:A1,A1)+1))&","&IF(ISERROR( SMALL(IF
(A$1:A$15=A1,ROW(A$1:A$15)),COUNTIF(A$1:A1,A1)-
1)),"none",SMALL(IF(A$1:A$15=A1,ROW(A$1:A$15)),COU NTIF
(A$1:A1,A1)-1))

Copy down as needed. This returns the actual row numbers
and not the position in the array.

Biff

-----Original Message-----
I have an array with 500+ elements. Assume elements 100,

200, 300, and 400
are equal to 'Sue'. For each occurrence of Sue, I want

to find the row
number for the next occurrence and for the previous

occurrence. At 100, I
get 200 and 'none'. At 200, I get 300 and 100. But when

I get to 300, I get
400 and 100, altho I want 400 and 200. When I am at 300,

is there some way
to have the search start at 299 and search backwards so

that the first match
it comes to is at 200?

--
Bill @ UAMS
.

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
MATCH function JayL Excel Worksheet Functions 0 March 5th 05 01:27 AM
Match function selecting first value it matches on exactly Paul K. Excel Worksheet Functions 1 February 24th 05 08:57 PM
Need Formula or Function to calculate Margin (reverse of Percent a Ken Excel Worksheet Functions 1 February 7th 05 09:26 AM
Need help on index and match function Susan Hayes Excel Worksheet Functions 2 December 22nd 04 10:31 PM
Offset, indirect, match function limitation on linked worksheets. NewAlgier Excel Worksheet Functions 1 December 6th 04 11:55 PM


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