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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:16:05+00:00 2026-05-31T21:16:05+00:00

I’m trying to get an Excel function to return more arguments than are passed

  • 0

I’m trying to get an Excel function to return more arguments than are passed to it initially. It’s been a while since I used Excel VBA, but I was wondering if it is possible to do this? Here is the code I’ve been developing.

The function (“SelectColumn”) needs to return 6 values, and I’ve got them as arguments in the code below.
Many thanks for any help.

Sub match_names3()
 Dim i As Integer
 Dim strRow, strCol As Integer
 Dim UpBound, LowBound As Range

 Dim strUpBoundRow, strUpBoundColumn, strLowBoundRow, strLowBoundColumn As Integer
 Dim CompareRange_alum_names As Range
 Dim CompareRange_bio_names As Range
 Dim alum As Variant, bio As Variant
 Dim AlumCount, BioCount As Long
 strRow = 2
 strCol = 8
 strUpBoundRow = 0
 strUpBoundColumn = 0
 strLowBoundRow = 0
 strLowBoundColumn = 0

 SelectColumn strRow, strCol, strUpBoundRow, strUpBoundColumn, strLowBoundRow, strLowBoundColumn


 Set CompareRange_alum_names = Worksheets("Sheet1").Range(Cells(strUpBoundRow, strUpBoundColumn) & ":" & Cells(strLowBoundRow, strLowBoundColumn))


 strRow = 2
 strCol = 17
 strUpBoundRow = 0
 strUpBoundColumn = 0
 strLowBoundRow = 0
 strLowBoundColumn = 0

 SelectColumn strRow, strCol, strUpBoundRow, strUpBoundColumn, strLowBoundRow, strLowBoundColumn


 Set CompareRange_alum_names = Worksheets("Sheet1").Range(Cells(strUpBoundRow, strUpBoundColumn) & ":" & Cells(strLowBoundRow, strLowBoundColumn))

 AlumCount = 2
     For Each alum In CompareRange_alum_names

      BioCount = 2
         For Each bio In CompareRange_bio_names

             If bio.Value = alum.Value Then

             Cells(AlumCount, 19).Value = Cells(BioCount, 16)
             End If
          BioCount = BioCount + 1
          Next bio

     AlumCount = AlumCount + 1
     Next alum


 End Sub



 Function SelectColumn(ByVal strRow As Integer, ByVal strCol As Integer, ByVal strUpBoundRow As Integer, ByVal strUpBoundColumn As Integer, ByVal strLowBoundRow As Integer, ByVal strLowBoundColumn As Integer)

 Dim UpBound As Range
 Dim LowBound As Range

 Worksheets("Sheet1").Cells(strRow, strCol).Select

 If ActiveCell.Row > 1 Then
     If IsEmpty(ActiveCell.Offset(-1, 0)) Then
     Set UpBound = ActiveCell
     Else
     Set UpBound = ActiveCell.End(xlUp)
     End If
 Else
     Set UpBound = ActiveCell
 End If
 strUpBoundRow = UpBound.Row
 strUpBoundColumn = UpBound.Column
 MsgBox ("strUpBoundRow " & strUpBoundRow)
 MsgBox ("strUpBoundColumn " & strUpBoundColumn)


 If ActiveCell.Row < Rows.Count Then
     If IsEmpty(ActiveCell.Offset(1, 0)) Then
     Set LowBound = ActiveCell
     Else
     Set LowBound = ActiveCell.End(xlDown)
     End If
 Else
     Set LowBound = ActiveCell
 End If
 strLowBoundRow = LowBound.Row
 strLowBoundColumn = LowBound.Column
 MsgBox ("strLowBoundRow " & strLowBoundRow)
 MsgBox ("strLowBoundColumn " & strLowBoundColumn)


 Range(UpBound, LowBound).Select


 Set UpBound = Nothing
 Set LowBound = Nothing

 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-31T21:16:07+00:00Added an answer on May 31, 2026 at 9:16 pm

    To further elucidate Tim Williams’ comment, passing values ByRef means a reference to the (memory) location of the variables will be given to the SelectColumn function. Inside the SelectColumn function, when one of those variables is changed, the function will change the value of the variable at that reference, i.e. the original variable.

    When you pass a variable ByVal, a duplicate of that variable is generated. This exists only within the SelectColumn function. If you change it inside SelectColumn it changes this duplicate, rather than the original.

    Edit:

    You’ll need to change your declarations. When you declare the following:

    Dim strRow, strCol As Integer
    

    You expect strRow and strCol to both be integers, however, strRow is a variant, strCol is an integer (This goads me greatly). You need to declare these as follows:

    Dim strRow as Integer, _
        strCol as integer
    

    Similarly with a number of your other declarations.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT

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.