Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

A VBA Solution to using the MCONCAT Function from the Morefunc Add-in

Posted on 2010-11-30
3
Medium Priority
?
1,613 Views
Last Modified: 2012-05-10
Good Afternoon

Having got a working solution, to a previous question, which is only hampered by the IT Policy, I am looking for a VBA work around. The original problem:

Please see the Excel workbook for further details - warning contains a formula which requires the Morefunc add-in

I am trying to match a list of items(Column C) to a given location(Column A), to help with future amendments to both the location and list of items I would like to refference a refference type table. Its this arrangement between the data and the refference table that makes me think of a VLookup?

A full example can be seen in the workbook, where column E refferes to what I would like to be left with. Each item has its own unique code and is in the following format:

Item;#Number;#

The solution, which works is the use of the MCONCAT function from the Morefunc add-in, with the following:

=MCONCAT(IF(ISNUMBER(1/SEARCH(Information!B$2:B$15,C2)/(A2=Information!A$2:A$15)),Information!B$2:B$15,""))

I have had a Google search of the VBA functionality for the AConcat as suggested, but VBA is outside my comfort zone.

Any ideas

Many thanks
Example.xls
0
Comment
Question by:Washcare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 34239448
Here's a basic version - demo in the attached file.

Public Function Concat(Target As Variant, Optional strSeparator As String = ", ") As String
    Dim varItem, lngIndex As Long
    If UBound(Target, 1) >= 0 Then
        For lngIndex = LBound(Target, 1) To UBound(Target, 1)
            If Len(Target(lngIndex, 1)) > 0 Then Concat = Concat & strSeparator & Target(lngIndex, 1)
        Next lngIndex
      If Len(Concat) > 0 Then Concat = Mid$(Concat, Len(strSeparator) + 1)
   End If
End Function

Open in new window

Example--1-.xls
0
 

Author Closing Comment

by:Washcare
ID: 34239508
Many thanks
0
 
LVL 50

Expert Comment

by:Dave Brett
ID: 34243677
It would be best to group the shorter strings together to savoid adding the longer string twice

Concat = Concat & (strSeparator & Target(lngIndex, 1))

Cheers

Dave
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question