Advertisement

06.09.2008 at 08:00AM PDT, ID: 23469281
[x]
Attachment Details

Is it possible to pass multiple ranges to a Function?

Asked by Merch_Ops in Microsoft Excel Spreadsheet Software, Microsoft Office Suite, Visual Basic Programming

Tags: , ,

Hi,
I've got a simple concatenation function (which I've included below). I'd like to be able to choose multiple ranges and pass them to the function, for example concat((H10:K10,H13:H14,E8:F12))

Problem is that the comma separates the statements passed to the function and so causes an error...

Any ideas?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
Public Function Concat(Target As Range, Optional Separator As String = ",") As String
    Dim cell As Range
    Dim blnFirst As Boolean
    
    blnFirst = True
    Concat = ""
    For Each cell In Target
        If Not blnFirst Then
            Concat = Concat & Separator
        Else
            blnFirst = False
        End If
        Concat = Concat & cell.Value
    Next
End Function
 
Loading Advertisement...
 
[+][-]06.09.2008 at 08:05AM PDT, ID: 21743736

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 08:11AM PDT, ID: 21743780

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 08:17AM PDT, ID: 21743843

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 08:21AM PDT, ID: 21743883

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 08:24AM PDT, ID: 21743916

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.09.2008 at 08:33AM PDT, ID: 21743984

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Excel Spreadsheet Software, Microsoft Office Suite, Visual Basic Programming
Tags: Microsoft, Excel, 2003
Sign Up Now!
Solution Provided By: rorya
Participating Experts: 2
Solution Grade: A
 
 
[+][-]06.09.2008 at 09:31AM PDT, ID: 21744495

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628