Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Return all matching cell values

I don't do much vba but I have a problem that I cannot figure out how
to begin solving:

I have a worksheet called "aliases" as follows:

column a column b
table_name alias_name
customer customer1
customer customer2
sales sales2
sales sales2
site site1

What I need to do is create a function or procedure that takes
table_name as an input parameter and returns all matching alias
values.

For example, I would pass "customer" to the process and it would
return 'customer1 and customer2" so I can pass those values into
another procedure.

Regards,

Ken

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Return all matching cell values

Use code like this:

Function GetAliases(s1 as String) as String
Dim rng As Range
Dim sAddr As String
Dim s1 as String, s as String
's1 = InputBox("Enter the Name to lookup")
if s1 = "" then exit sub

With Sheets("aliases").Columns(1)
Set rng = .Find(What:=s1, _
After:=ActiveCell, _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not rng Is Nothing Then
sAddr = rng.Address
Do
s = s & rng.offset(0,1).Value & vbNewLine
Set rng = .FindNext(rng)
Loop Until rng.Address = sAddr
End If
End With

if s < "" then
s = left(s,len(s)-1)
End if
GetAliases = s
End Function

--
Regards,
Tom Ogilvy


" wrote:

I don't do much vba but I have a problem that I cannot figure out how
to begin solving:

I have a worksheet called "aliases" as follows:

column a column b
table_name alias_name
customer customer1
customer customer2
sales sales2
sales sales2
site site1

What I need to do is create a function or procedure that takes
table_name as an input parameter and returns all matching alias
values.

For example, I would pass "customer" to the process and it would
return 'customer1 and customer2" so I can pass those values into
another procedure.

Regards,

Ken


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 200
Default Return all matching cell values

wrote:
. . .I have a worksheet called "aliases" as follows:

column a column b
table_name alias_name
customer customer1
customer customer2
sales sales2
sales sales2
site site1

What I need to do is create a function or procedure that takes
table_name as an input parameter and returns all matching alias
values. . . .


If the functions in the freely downloadable file at
http://home.pacbell.net/beban are available to your workbook, you might
consider

=VLOOKUPS("customer", lookup_array, 2)

array entered into a column of cells sufficient to accommodate the output.

Alan Beban
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
Lookup one value, Return matching correspnding values JJ Excel Worksheet Functions 7 January 12th 10 12:29 AM
Lookup to return multiple matching values olssonj Excel Worksheet Functions 5 June 22nd 09 10:13 AM
Look up two values in different columns and return matching value Ash Excel Discussion (Misc queries) 5 March 3rd 09 08:02 AM
Lookup 3 matching values of which one is a range and return a sum Cheryl Excel Worksheet Functions 2 November 30th 08 05:22 AM
Return all matching values [email protected] Excel Worksheet Functions 4 August 9th 06 04:02 AM


All times are GMT +1. The time now is 06:19 AM.

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"