Welcome to the Excel Forum

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed.

Please Register to Remove these Ads

Please Register to Remove these Ads



Reply
  #1  
Old 06-29-2009, 08:29 AM
antoni.konarski antoni.konarski is offline
Registered User
 
Join Date: 29 Jun 2009
Location: Warsaw, Poland
MS Office Version:Excel 2003
Posts: 4
antoni.konarski is becoming part of the community
Combining search results into one cell

Please Register to Remove these Ads

Hi everybody

I am a new forum user and I'm not a frequent Excel user...

I have a list of room numbers and room types. I would like to find all rooms of a given type (eg. KR01L) and list all room numbers that match this type.
It would be great to have it in one cell like "109, 114, 123...".

Thanks

AK
Attached Files
File Type: xls Room count.xls (39.0 KB, 5 views)

Last edited by antoni.konarski; 07-02-2009 at 08:04 AM.
Reply With Quote
  #2  
Old 06-29-2009, 09:06 AM
NBVC's Avatar
NBVC NBVC is offline
Forum Guru
 
Join Date: 06 Dec 2006
Location: Mississauga, CANADA
MS Office Version:2003 & 2007
Posts: 18,489
NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future
Re: Combining search results into one cell

Try this UDF from Harlon Grove:

Code:
Function ACONCAT(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant

If TypeOf a Is Range Then
For Each y In a.Cells
ACONCAT = ACONCAT & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
ACONCAT = ACONCAT & y & sep
Next y
Else
ACONCAT = ACONCAT & a & sep
End If

ACONCAT = Left(ACONCAT, Len(ACONCAT) - Len(sep))
End Function
To apply the code, hit Alt+F11 and then go to Insert|Module and paste the above in the editor window.

Then in your sheet apply formula:

Code:
=SUBSTITUTE(TRIM(ACONCAT(IF($B$2:$B$315=E2,$A$2:$A$315,"")," "))," ",",")
Where E2 contains Type to Filter for...

The formula must be confirmed with CTRL+SHIFT+ENTER not just ENTER
__________________
Where there is a will there are many ways. Pick One!

Please read the Forum Rules

If you are happy with the results, please add to my reputation by clicking the icon next to the Post # in the bar above my avatar (picture) in this post.

Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Reply With Quote
  #3  
Old 06-29-2009, 09:19 AM
antoni.konarski antoni.konarski is offline
Registered User
 
Join Date: 29 Jun 2009
Location: Warsaw, Poland
MS Office Version:Excel 2003
Posts: 4
antoni.konarski is becoming part of the community
Re: Combining search results into one cell

Great!
Thanks a lot.
Is this Module now stored in the .xls file?

Cheers
A
Reply With Quote
  #4  
Old 06-29-2009, 09:21 AM
NBVC's Avatar
NBVC NBVC is offline
Forum Guru
 
Join Date: 06 Dec 2006
Location: Mississauga, CANADA
MS Office Version:2003 & 2007
Posts: 18,489
NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future
Re: Combining search results into one cell

Quote:
Originally Posted by antoni.konarski View Post
Great!
Thanks a lot.
Is this Module now stored in the .xls file?

Cheers
A
Yes it is.
__________________
Where there is a will there are many ways. Pick One!

Please read the Forum Rules

If you are happy with the results, please add to my reputation by clicking the icon next to the Post # in the bar above my avatar (picture) in this post.

Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Reply With Quote
  #5  
Old 06-29-2009, 09:47 AM
NBVC's Avatar
NBVC NBVC is offline
Forum Guru
 
Join Date: 06 Dec 2006
Location: Mississauga, CANADA
MS Office Version:2003 & 2007
Posts: 18,489
NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future
Re: Combining search results into one cell

Please do remember to mark your thread as Solved.

How to mark a thread Solved
Go to the first post
Click edit
Click Go Advanced
Just below the word Title you will see a dropdown with the word No prefix.
Change to Solved
Click Save
__________________
Where there is a will there are many ways. Pick One!

Please read the Forum Rules

If you are happy with the results, please add to my reputation by clicking the icon next to the Post # in the bar above my avatar (picture) in this post.

Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Reply With Quote
  #6  
Old 07-02-2009, 03:31 AM
antoni.konarski antoni.konarski is offline
Registered User
 
Join Date: 29 Jun 2009
Location: Warsaw, Poland
MS Office Version:Excel 2003
Posts: 4
antoni.konarski is becoming part of the community
Re: Combining search results into one cell

The macro is working (thanks again NBVC!), but only when I have the Security Level set to Low. The main problem is that other people I'm working with would all have to change their Security Level.

I have "Trust all installed add-ins and templates" checked.

At the moment it seems like the only way to use macros is to set the Security Level for Macros to Low. Doesn't make sense, does it?

Do you know how to solve it?
Reply With Quote
  #7  
Old 07-02-2009, 07:49 AM
NBVC's Avatar
NBVC NBVC is offline
Forum Guru
 
Join Date: 06 Dec 2006
Location: Mississauga, CANADA
MS Office Version:2003 & 2007
Posts: 18,489
NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future NBVC has a brilliant future
Re: Combining search results into one cell

Well, that is why it is called Security Level.. I would advise your users to set security to medium.. then upon opening the file you will get asked whether to enable or disable macros... this is microsoft's way of protecting (or allowing you to choose your protection) against viruses within macros.
__________________
Where there is a will there are many ways. Pick One!

Please read the Forum Rules

If you are happy with the results, please add to my reputation by clicking the icon next to the Post # in the bar above my avatar (picture) in this post.

Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.
Reply With Quote
  #8  
Old 07-02-2009, 08:04 AM
antoni.konarski antoni.konarski is offline
Registered User
 
Join Date: 29 Jun 2009
Location: Warsaw, Poland
MS Office Version:Excel 2003
Posts: 4
antoni.konarski is becoming part of the community
Re: Combining search results into one cell

Thanks
Cheers
A
Reply With Quote


Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump