DeanP
02-04-2019, 04:21 AM
I am using vlookup to return a date from my spreadsheet. I have tried to convert the date to Long by using CLng & CDate in
my code, but I am still getting a type mismatch error.
Here is my code:
Private Sub TextBox9_Change()
Dim wsJournal As Worksheet
Dim MyDate As Long
Set wsJournal = Worksheets("Journal")
MyDate = CLng(CDate(Me.tbDate.Value))
MyDate = Application.VLookup(Me.tbPeriod, [YrDte], 1, False)
End Sub
Debugger shows that the error is in this line:
MyDate = CLng(DateValue(Me.tbDate.Value))
I've also tried: MyDate = CLng(CDate(Me.tbDate.Text)), Dim As Date, Dim As Double - but still the same error!
Any advice would be appreciated.
my code, but I am still getting a type mismatch error.
Here is my code:
Private Sub TextBox9_Change()
Dim wsJournal As Worksheet
Dim MyDate As Long
Set wsJournal = Worksheets("Journal")
MyDate = CLng(CDate(Me.tbDate.Value))
MyDate = Application.VLookup(Me.tbPeriod, [YrDte], 1, False)
End Sub
Debugger shows that the error is in this line:
MyDate = CLng(DateValue(Me.tbDate.Value))
I've also tried: MyDate = CLng(CDate(Me.tbDate.Text)), Dim As Date, Dim As Double - but still the same error!
Any advice would be appreciated.