Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9273129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:02:18+00:00 2026-06-18T16:02:18+00:00

Does anyone know how to use a VBA function within a worksheet based call

  • 0

Does anyone know how to use a VBA function within a worksheet based call to SUMPRODUCT?

This works fine, summing the values in column N where column L contains “Y” and col A contains a different value to col K…

=SUMPRODUCT(--(Input!L1:L100="Y"), --(Input!A1:A100<>Input!K1:K100), Input!N1:N100)

But I want to be able to apply more logic than just A<>K in my second criteria, something like this…

=SUMPRODUCT(--(Input!L1:L100="Y"), --(MatchNames(Input!A1:A100,Input!K1:K100)), Input!N1:N100)

I have a function called MatchNames in my VBA, but I can’t work out what it needs to return in order to work. I’ve tried returning an array of boolean, integer (set to 0 or 1), I’ve tried transposing the results before returning them, but nothing is working. I’ve debugged through the MatchNames function, and it does return something “useful” (i.e. an array of booleans), so it’s not that the function is bombing out part way through, but I get #VALUE! when I try to use it in a SUMPRODUCT.

This is my VBA function…

Public Function MatchNames(ByVal rng1 As Range, rng2 As Range) As Boolean()
    Dim blnOut() As Boolean
    Dim k As Long

    ReDim blnOut(rng1.Rows.Count - 1)

    For k = 1 To rng1.Rows.Count
        If rng1.Cells(k, 1).Value <> "" Then
            If rng1.Cells(k, 1).Value <> rng2.Cells(k, 1).Value Then
                blnOut(k - 1) = True
            End If
        End If
    Next

    MatchNames = blnOut
End Function
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:02:19+00:00Added an answer on June 18, 2026 at 4:02 pm

    I think your MatchNames array needs to be transposed as you suggest (because it appears to be returning the equivalent of a row of values – which doesn’t work with the other columns of values in SUMPRODUCT).

    I don’t know how you’d transpose that in VBA but if you can’t do that then transpose in SUMPRODUCT like

    =SUMPRODUCT(--(input!L1:L100="Y"),--TRANSPOSE(MatchNames(input!A1:A100,input!K1:K100)), input!N1:N100)

    but use of TRANSPOSE means that formula now needs to be “array-entered” with CTRL+SHIFT+ENTER

    …or you can use MMULT which will multiply a 1×100 range by a 100×1, i.e.

    =MMULT(MatchNames(input!A1:A100,input!K1:K100)+0,input!N1:N100*(input!L1:L100="Y"))

    for that latter formula to work the sum range – input!N1:N100 – must be all numeric

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know I can use Request.Browser.IsMobileDevice . But does anyone know how it works,
Does anyone know how to use the define function and pass a variable into
Does anyone know what the syntax is to use the file revision keyword within
Does anyone know how to use the l() or url() function to create mailto
Does anyone know how to use transact sql to enumerate the column types within
Does anyone know how to use Java to create sub-directories based on the alphabets
Does anyone know how to use the subset.ff function in the ff package? Here
Does anyone know anyway to use something similar to polygon.getKml() except for the current
Does anyone know how to use an icon instead of text for the UINavigationController
Does anyone know how to use the command line compiler ('cl' and 'link') in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.