Hello
How can i list down the in-between dates in (dd-mmm-yyyy) format from below textboxes ie txtFromDate.text and txtToDate.Text
also the list to contain the dates txtFromDate.Text and txtToDate.text with in-between dates
Thanks NimishK
How can i list down the in-between dates in (dd-mmm-yyyy) format from below textboxes ie txtFromDate.text and txtToDate.Text
also the list to contain the dates txtFromDate.Text and txtToDate.text with in-between dates
Code:
Option Explicit
Dim fromDate As Date, toDate As Date
Private Sub txtFromDate_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If txtFromDate.Value = vbNullString Then
Exit Sub
ElseIf Not IsDate(txtFromDate.Value) Then
Cancel = True
MsgBox "Invalid date, please re-enter", vbCritical
txtFromDate.Value = vbNullString
txtFromDate.SetFocus
'MsgBox "Invalid date, please re-enter", vbCritical
Exit Sub
End If
fromDate = DateSerial(Year(Date), Month(Date), Day(Date))
txtFromDate.Value = Format(CDate(txtFromDate.Value), "dd-mmm-yyyy")
End Sub
Private Sub txtToDate_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
If txtToDate.Value = vbNullString Then
Exit Sub
ElseIf Not IsDate(txtToDate.Value) Then
Cancel = True
MsgBox "Invalid date, please re-enter", vbCritical
txtToDate.Value = vbNullString
txtToDate.SetFocus
'MsgBox "Invalid date, please re-enter", vbCritical
Exit Sub
End If
toDate = DateSerial(Year(Date), Month(Date), Day(Date))
txtToDate.Value = Format(CDate(txtToDate.Value), "dd-mmm-yyyy")
End Sub
Last edited: