title: Excel VBA - Values Not Returning From Function
body: <p>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.</p>
  
  <p>The function ("SelectColumn") needs to return 6 values, and I've got them as arguments in the code below.
  Many thanks for any help.  </p>
  
  <pre><code>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) &amp; ":" &amp; 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) &amp; ":" &amp; 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 &gt; 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 " &amp; strUpBoundRow)
   MsgBox ("strUpBoundColumn " &amp; strUpBoundColumn)
  
  
   If ActiveCell.Row &lt; 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 " &amp; strLowBoundRow)
   MsgBox ("strLowBoundColumn " &amp; strLowBoundColumn)
  
  
   Range(UpBound, LowBound).Select
  
  
   Set UpBound = Nothing
   Set LowBound = Nothing
  
   End Function
  </code></pre>