Solved

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

Posted on 2010-11-30
3
1,561 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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

752 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