B
Bryan
I have a function that I need to return a string. The problem is that it
does not recognize the name in the spreadsheet. The code is in a module as
follows:
Function ListShorts(ColA As String, Row1 As Integer, ColB As String, Row2 As
Integer) As String
' Given a 2 column range, with part numbers on the left and quantity on the
right, create a string that has
' all the part numbers and quantities.
Dim Holder As String
Holder = Worksheets(1).Cells(ColA, Row1).Value & " -" &
Worksheets(1).Cells(ColB, Row1).Value & "pcs"
For i = (Row1 + 1) To Row2
Holder = Holder & " " & Worksheets(1).Cells(ColA, i).Value & " -" &
Worksheets(1).Cells(ColB, i).Value & "pcs"
Next i
ListShorts = Holder
End Function
The cell formula is as follows:
=ListShorts("B",6,"C",22)
Any ideas what I'm doing wrong? Also, if possible, I need the columns to be
able to grow or shrink, say a maximum of 25, and not glitch on null cells.
I'm not sure how to add that into the VBA. TIA
does not recognize the name in the spreadsheet. The code is in a module as
follows:
Function ListShorts(ColA As String, Row1 As Integer, ColB As String, Row2 As
Integer) As String
' Given a 2 column range, with part numbers on the left and quantity on the
right, create a string that has
' all the part numbers and quantities.
Dim Holder As String
Holder = Worksheets(1).Cells(ColA, Row1).Value & " -" &
Worksheets(1).Cells(ColB, Row1).Value & "pcs"
For i = (Row1 + 1) To Row2
Holder = Holder & " " & Worksheets(1).Cells(ColA, i).Value & " -" &
Worksheets(1).Cells(ColB, i).Value & "pcs"
Next i
ListShorts = Holder
End Function
The cell formula is as follows:
=ListShorts("B",6,"C",22)
Any ideas what I'm doing wrong? Also, if possible, I need the columns to be
able to grow or shrink, say a maximum of 25, and not glitch on null cells.
I'm not sure how to add that into the VBA. TIA