Mike Neal
Mike Neal

Reputation: 1

How to pass LastRow to a function

I am trying to find the last row in Column A, add a couple values from combobox selections in Columns A & B then call a pop up calendar (The on written by Trevor Eyre.) and have the date I select written to Column E. With the code I posted below everything works but I have to select and click the date 3 times before it enters it. How do I modify the code so 1 click does it? Anyone able to point me in the right direction? Thank you.

    Dim ws As Worksheet
    Set ws = Sheet1
    Dim LastRow As Long, i As Long
       
    LastRow = Sheets("PM Schedule").Cells(Rows.Count, 1).End(xlUp).row

    For i = LastRow To 1 Step -1
    
        If Sheets("PM Schedule").Cells(i, 1) <> " " Then
        
            LastRow = i + 1
            
            Exit For
        
        End If
     
    Next

    ASSETS_ID_NUMBER_INPUT_BOX_2.value = UCase(ASSETS_ID_NUMBER_INPUT_BOX_2.value)
    ASSETS_ALL_MAINT_TASKS_LIST.value = UCase(ASSETS_ALL_MAINT_TASKS_LIST.value)

    Sheet1.Cells(LastRow, 1).value = ASSETS_ID_NUMBER_INPUT_BOX_2.value
    Sheet1.Cells(LastRow, 2).value = ASSETS_ALL_MAINT_TASKS_LIST.value

    Dim dateVariable As Date
    dateVariable = CalendarForm.GetDate
    CalendarForm.GetDate
    
    MyDate = CalendarForm.GetDate
    
    If MyDate > 0 Then

        Sheet1.Cells(LastRow, 5).value = MyDate
    
    End If

End Sub

Upvotes: 0

Views: 50

Answers (1)

RetiredGeek
RetiredGeek

Reputation: 3168

Per Mike67 you are making three calls (three clicks) to the calendar routine:

enter image description here

Upvotes: 1

Related Questions