Advertisement

08.24.2008 at 02:41PM PDT, ID: 23674101
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

How do I refer to a named range  within a User-Defined Function?

Asked by TexasMepl in Microsoft Excel Spreadsheet Software, Visual Basic Programming

Tags: , ,

I am developing a user-defined function (UDF) that needs to switch between six possible named ranges:

GROUP A
"Bids_A" (on worksheet "Bids-A")
"Bids_A_GID" (on worksheet "Bids-A")
"Bids_A_Officials" (on worksheet "Bids-A")

GROUP B
"Bids_B" (on worksheet "Bids-B")
"Bids_B_GID" (on worksheet "Bids-B")
"Bids_B_Officials" (on worksheet "Bids-B")

I'm able to make it work perfectly as long as I bring the named ranges into the UDF through six respective arguments:

Private Function Assignment_Bids(bidchoice As Range, gid As Range, officials As Range, _
                bids_a As Range, bids_a_gid As Range, bids_a_officials As Range, _
                bids_b As Range, bids_b_gid As Range, bids_b_officials As Range) As Variant
    With Application
        Select Case bidchoice
            Case "Bids-A"
                Assignment_Bids = .Index(bids_a, .Match(gid, bids_a_gid, 0), .Match(officials, bids_a_officials, 0))
            Case "Bids-B"
                Assignment_Bids = .Index(bids_b, .Match(gid, bids_b_gid, 0), .Match(officials, bids_b_officials, 0))
        End Select
    End With
End Function

But this appears to be very cumbersome way to handle this. I would like to refer to the six named ranges above within the body of the UDF (and reduce the number of arguments from 9 to 3):

Private Function Assignment_Bids(bidchoice As Range, gid As Range, officials As Range) As Variant
    Dim bids As Range
    Dim bids_gid As Range
    Dim bids_officials As Range
    Select Case bidchoice
        Case "Bids-A"
            bids = Sheets("Bids-A").Range("Bids_A")
            bids_gid = Sheets("Bids-A").Range("Bids_A_GID")
            bids_officials = Sheets("Bids-A").Range("Bids_A_Officials")
        Case "Bids-B"
            bids = Sheets("Bids-B").Range("Bids_B")
            bids_gid = Sheets("Bids-B").Range("Bids_B_GID")
            bids_officials = Sheets("Bids-B").Range("Bids_B_Officials")
    End Select
    With Application
        Assignment_Bids = .Index(bids, .Match(gid, bids_gid, 0), .Match(officials, bids_officials, 0))
    End With
End Function

But I keep getting an error which I assume has to do with the way I'm trying to assign the various name ranges to the 3 noted variables (bids, bids_gid & bids_officials).

Any suggestions?

Thanks,
MarkStart Free Trial
[+][-]08.24.2008 at 02:53PM PDT, ID: 22302168

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

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

 
[+][-]08.24.2008 at 04:04PM PDT, ID: 22302350

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

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

 
[+][-]08.24.2008 at 06:17PM PDT, ID: 22302658

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.

 
[+][-]08.24.2008 at 06:27PM PDT, ID: 22302681

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.

 
[+][-]08.24.2008 at 06:42PM PDT, ID: 22302724

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, Visual Basic Programming
Tags: Microsoft, Excel/VBA, 2003
Sign Up Now!
Solution Provided By: TexasMepl
Participating Experts: 2
Solution Grade: A
 
 
[+][-]08.24.2008 at 07:52PM PDT, ID: 22302903

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.

 
[+][-]08.25.2008 at 04:52AM PDT, ID: 22304678

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.

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