View Single Post
  #1 (permalink)  
Old October 26th, 2005, 11:16 AM
zayasv zayasv is offline
Authorized User
 
Join Date: Oct 2005
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default weird program flow with nested loops

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
__________________
vmz
Reply With Quote