K
Kay
Hi
I use Excel 2002 and am stumbling on how to return a VBA array to a
spreadsheet
I have the below function which calcs the workdays between 2 parameter
dates.
When executed it returns only the first element rather than the whole
array
Any suggestions on where I am going wrong? Thanks, Kay
Public Function get_workdays(dteStart As Date, dteEnd As Date) As
Variant
Dim dteTEST As Date
Dim i As Integer
Dim varArray() As Variant
Dim iDays As Integer
iDays = NETWORKDAYS(dteStart, dteEnd)
ReDim varArray(iDays - 1)
varArray(0) = dteStart
i = 1
For i = 1 To UBound(varArray)
varArray(i) = workday(varArray(i - 1), 1)
Next i
get_workdays = Application.WorksheetFunction.Transpose(varArray)
End Function
I use Excel 2002 and am stumbling on how to return a VBA array to a
spreadsheet
I have the below function which calcs the workdays between 2 parameter
dates.
When executed it returns only the first element rather than the whole
array
Any suggestions on where I am going wrong? Thanks, Kay
Public Function get_workdays(dteStart As Date, dteEnd As Date) As
Variant
Dim dteTEST As Date
Dim i As Integer
Dim varArray() As Variant
Dim iDays As Integer
iDays = NETWORKDAYS(dteStart, dteEnd)
ReDim varArray(iDays - 1)
varArray(0) = dteStart
i = 1
For i = 1 To UBound(varArray)
varArray(i) = workday(varArray(i - 1), 1)
Next i
get_workdays = Application.WorksheetFunction.Transpose(varArray)
End Function