Solved

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

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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

622 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