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 1033283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:12:33+00:00 2026-05-16T14:12:33+00:00

With SUM for instance, I can do things like: =SUM(F5:F7,F6:F8,A1,E7:G7,F7,2,7) Which takes multiple ranges

  • 0

With SUM for instance, I can do things like:

=SUM(F5:F7,F6:F8,A1,E7:G7,F7,2,7)

Which takes multiple ranges and/or individual cells and it adds them all up. My question is how do I do this with a VBA function, e.g. to generalize a binary XOR:

Function BXOR(A As Integer, B As Integer) As Integer
    BXOR = CLng(A) Xor CLng(B)
End Function

It gets old fast when I have to =BXOR(BXOR(BXOR(w,x),y),z)


Generalized version of Marco’s function:

Function BXOR(ParamArray vars() As Variant) As Long
    Dim i,j As Long
    BXOR = 0

    For i = 0 To UBound(vars)
        If Not IsObject(vars(i)) Then
            ' Handle explicitly passed integer arguments, e.g. BXOR(1,[...])
            BXOR = BXOR Xor CLng(vars(i))
        ElseIf IsArray(vars(i).Value2) Then
            ' Handle 1-D ranges of cells, e.g. BXOR(A1:A3,[...])
            For j = 1 To UBound(vars(i).Value2)
                BXOR = BXOR Xor CLng(vars(i)(j).Value2)
            Next j
        Else
            ' Handle individual cells, e.g. BXOR(A1,[...])
            BXOR = BXOR Xor CLng(vars(i).Value2)
        End If
    Next i
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-05-16T14:12:34+00:00Added an answer on May 16, 2026 at 2:12 pm

    I think that you are looking for a ParamArray

    Your code should look like this:

    Function BXor(ParamArray vars() As Variant) as Long
        Dim i As Long
        Dim tmp As Long
    
        For i = 0 To UBound(vars)
            tmp = tmp Xor clng(vars(i))
        Next
    
        BXor = tmp
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I get each element's width and sum them up? For instance, here
sum( int(i.replace(',',''))if re.search('\d',i)!=None for i in list) I would like to sum all elements
I have figured out that I can use hibernate to get the sum of
I would like to know how can I create a 'dynamic intent' in android.
I'm hoping to implement something like all of the great plugins out there for
imagine something like this: import class B.*; interface A supports A.testSum { int sum(
SELECT sum(TotalHoursM) + (TotalHoursT) + (TotalHoursW) + (TotalHoursTH) + (TotalHoursF) AS TOTAL FROM LeaveRequest
Simple sum of digits code. It compiles but when executed, the last cout gives
To sum it up, there are two basic trains of thought: The private field
SELECT SUM(a.Clicks) AS Clicks, SUM(b.NoOfUsers) Users, c.WEEK_NUM, b2.ALL_TASKS FROM (SELECT SUM(CLICK_CNT) AS Clicks, TO_CHAR(RQST_DT,'YYYY-MM-DD')

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.