Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How to Search, Count, Match and Post Values


Greetings All,

I am new to this forum, so excuse me if I stumble. I must find a way
to accomplish the following: Search below a cell for the next matching
cell, and post all of the "unique" values included in the search,
including the matched value, post these adjacent to the referenced
cell. For example, given the following row:

2 - (This is my reference cell, the one I want to match)
6
5
5
7
4
3
3
2 - (this is my matched cell)

In the example above, I passed the values 6,5,7,4 and 3 before finding
the match of 2. I would like to be able to post in the cell directly
to the right of the reference cell the values 6,5,7,4,3,2 (yes I need
to include the referenced value). I could also accept a cumulative
total of unique values in the adjacent cell. In this case that value
would be 6 (6 unique values - I do not want a total of values, which
would be 8, because some values are repeats like 5 and 3). The
cumulative total method would be preferable actually.

I would then need to copy the formula to each cell below, so that it
would in turn likewise. So after the 2 above, the formula would work
on the 6 then 5 then 5 etc. I would simply drag the formula downward.
So assuming the example cells above were in column A, the formula would
reside in column B.

I am not expecting the answer here, (unless it is simple), but I
appreciate any suggestions.

Thank you,

Vincent


--
vincentws
------------------------------------------------------------------------
vincentws's Profile: http://www.excelforum.com/member.php...o&userid=37563
View this thread: http://www.excelforum.com/showthread...hreadid=571944

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How to Search, Count, Match and Post Values


This may not be the most elegant solution but here goes. If you paste
the function below into a module in your workbook you can use this
function in column B.


Code:
--------------------
Private Function MatchDupes(ByVal c As Range) As String
Dim a() As Integer
Dim i As Integer
Dim n As Integer
Dim x As Integer

i = 1
x = 0

Do While c.Value < c.Offset(i, 0).Value
If c.Offset(i, 0).Value < "" Then
Dim notDupe As Boolean
notDupe = True
If i < 1 Then
For n = 0 To UBound(a)
If c.Offset(i, 0).Value = a(n) Then
notDupe = False
Exit For
End If
Next n
If notDupe Then
ReDim Preserve a(x)
a(x) = c.Offset(i, 0).Value
x = x + 1
End If

Else
ReDim Preserve a(x)
a(x) = c.Offset(i, 0).Value
x = x + 1
End If
i = i + 1
Else
Exit Do
End If
Loop

If c.Value = c.Offset(i, 0).Value Then
ReDim Preserve a(x)
a(x) = c.Offset(i, 0).Value
End If


If i = 1 Then
MatchDupes = c.Offset(i, 0).Value
Else
Dim s As String
For n = 0 To UBound(a)
If n = 0 Then
s = a(n)
Else
s = s & ", " & a(n)
End If
Next n
MatchDupes = s
End If
End Function

--------------------


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=571944

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,688
Default How to Search, Count, Match and Post Values

Needs tweaked.

If there is no matching value it still returns the uniques. For example, in
the posted sample data 6 has no match but it still returns all the uniques
below the 6 but excludes the 6 as a unique.

Biff

"Excelenator"
wrote in message
...

This may not be the most elegant solution but here goes. If you paste
the function below into a module in your workbook you can use this
function in column B.


Code:
--------------------
Private Function MatchDupes(ByVal c As Range) As String
Dim a() As Integer
Dim i As Integer
Dim n As Integer
Dim x As Integer

i = 1
x = 0

Do While c.Value < c.Offset(i, 0).Value
If c.Offset(i, 0).Value < "" Then
Dim notDupe As Boolean
notDupe = True
If i < 1 Then
For n = 0 To UBound(a)
If c.Offset(i, 0).Value = a(n) Then
notDupe = False
Exit For
End If
Next n
If notDupe Then
ReDim Preserve a(x)
a(x) = c.Offset(i, 0).Value
x = x + 1
End If

Else
ReDim Preserve a(x)
a(x) = c.Offset(i, 0).Value
x = x + 1
End If
i = i + 1
Else
Exit Do
End If
Loop

If c.Value = c.Offset(i, 0).Value Then
ReDim Preserve a(x)
a(x) = c.Offset(i, 0).Value
End If


If i = 1 Then
MatchDupes = c.Offset(i, 0).Value
Else
Dim s As String
For n = 0 To UBound(a)
If n = 0 Then
s = a(n)
Else
s = s & ", " & a(n)
End If
Next n
MatchDupes = s
End If
End Function

--------------------


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile:
http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=571944



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default How to Search, Count, Match and Post Values


So if there is no matching value you do not want to return anything?


--
Excelenator


------------------------------------------------------------------------
Excelenator's Profile: http://www.excelforum.com/member.php...o&userid=36768
View this thread: http://www.excelforum.com/showthread...hreadid=571944

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1,688
Default How to Search, Count, Match and Post Values

Here's a formula that returns the unique count:

Entered as an array using the key combination of CTRL,SHIFT,ENTER:

Assuming your range is A2:A10 and there are no empty cells within that
range.

=IF(COUNTIF(A2:A$10,A2)=1,0,SUM(1/COUNTIF(A2:INDEX(A2:A$10,MATCH(A2,A3:A$10,0)+1),A2 :INDEX(A2:A$10,MATCH(A2,A3:A$10,0)+1))))

Copy down as needed.

Based on your sample, returns:

6;0;1;0;0;0;1;0;0

Biff

"vincentws" wrote in
message ...

Greetings All,

I am new to this forum, so excuse me if I stumble. I must find a way
to accomplish the following: Search below a cell for the next matching
cell, and post all of the "unique" values included in the search,
including the matched value, post these adjacent to the referenced
cell. For example, given the following row:

2 - (This is my reference cell, the one I want to match)
6
5
5
7
4
3
3
2 - (this is my matched cell)

In the example above, I passed the values 6,5,7,4 and 3 before finding
the match of 2. I would like to be able to post in the cell directly
to the right of the reference cell the values 6,5,7,4,3,2 (yes I need
to include the referenced value). I could also accept a cumulative
total of unique values in the adjacent cell. In this case that value
would be 6 (6 unique values - I do not want a total of values, which
would be 8, because some values are repeats like 5 and 3). The
cumulative total method would be preferable actually.

I would then need to copy the formula to each cell below, so that it
would in turn likewise. So after the 2 above, the formula would work
on the 6 then 5 then 5 etc. I would simply drag the formula downward.
So assuming the example cells above were in column A, the formula would
reside in column B.

I am not expecting the answer here, (unless it is simple), but I
appreciate any suggestions.

Thank you,

Vincent


--
vincentws
------------------------------------------------------------------------
vincentws's Profile:
http://www.excelforum.com/member.php...o&userid=37563
View this thread: http://www.excelforum.com/showthread...hreadid=571944





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, exclusion question Paul Lautman Excel Discussion (Misc queries) 4 July 21st 06 04:53 AM
Lookup Data in two seperate Spreadsheets Padraig Excel Worksheet Functions 6 June 28th 06 03:05 PM
Match then lookup Tenacity Excel Worksheet Functions 9 December 3rd 05 05:30 AM
match values in two different columns thomasNg Excel Worksheet Functions 2 November 24th 05 02:38 AM
Find a match that;s not exact Phyllis Excel Worksheet Functions 0 November 8th 04 08:12 PM


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