W
WLMPilot
I am having trouble pulling a value in a cell into a macro for calculations
The macro is below. The is executed when ENTER is clicked on userform.
It is suppose to pull a date in from the spreadsheet (B125:B176) and
evaluate it against date entered in userform.
Private Sub CommandButton1_Click()
Dim i As Double
Dim date1 As Date
Dim ttltime1, ttltime2 As Double
ttltime1 = Val(TextBox2) - Val(TextBox1)
ttltime2 = Hour(ttltime1) + (Minute(ttltime1) / 60)
With Worksheets("PAS")
For i = 125 To 176
date1 = .Cell(i, 2).Value <<< Problem code
If TextBox1 <= date1 Then
.Cell(i, (TextBox1 - date1) + 3).Value = ttltime2
i = 176
End If
Next
End With
End Sub
Thanks,
Les
The macro is below. The is executed when ENTER is clicked on userform.
It is suppose to pull a date in from the spreadsheet (B125:B176) and
evaluate it against date entered in userform.
Private Sub CommandButton1_Click()
Dim i As Double
Dim date1 As Date
Dim ttltime1, ttltime2 As Double
ttltime1 = Val(TextBox2) - Val(TextBox1)
ttltime2 = Hour(ttltime1) + (Minute(ttltime1) / 60)
With Worksheets("PAS")
For i = 125 To 176
date1 = .Cell(i, 2).Value <<< Problem code
If TextBox1 <= date1 Then
.Cell(i, (TextBox1 - date1) + 3).Value = ttltime2
i = 176
End If
Next
End With
End Sub
Thanks,
Les