weird program flow with nested functions
When the first function (LastDateInSheet) is executed from a form_load event, the program flow jumps from the 4th line to the function immediately below.
Public Function LastDateInSheet() As Date
Dim DateRow As Range, ws As Worksheet = wb.ActiveSheet
DateRow = ws.Range("2:2")
'Jumps from the line below to next function below ????
LastDateInSheet = Date.FromOADate(xl.WorksheetFunction.Max(DateRow))
DateRow = Nothing
ws = Nothing
End Function
--------------------------------------------------------------------
Public Function DateRange(ByVal D As Date) As Range
'Returns the location (range) of a date in vbGrid.xls
'ACTIVATES the sheet with the date
Dim WS As Worksheet
WS = wb.ActiveSheet
'Jumps to the line below ????????
DateRange = WS.Range("a2:ba2").Find(D)
If Not DateRange Is Nothing Then Exit Function
'If date is not on active sheet, then find it
' wb.ActiveSheet.GetType()
If WS.Name = "Data" Then wb.ActiveSheet.Previous.Activate()
any ideas??
vmz
__________________
vmz
|