Between dates

S

StephanieH

My end user is prompted to enter a date by
MyValue = InputBox("Which month would you like to review? YYYY_MM", "Central
Analytics")

How can I specify to run a procedure if the date entered falls between
2004_01 and 2004_06?


MyValue = InputBox("Which month would you like to review? YYYY_MM", "Central
Analytics")
If MyValue >= "2004_07" Then

Workbooks.Open Filename:="\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan
Recovery MIS\" & MyValue & "\Gross Placement Batch Tracks\Summary Data\" &
ListBox1.List(i) & " GBT Summary.xls"
Unload UserForm6
End If
If MyValue <= "2004_06" and >= "2004_01 Then
Workbooks.Open Filename:= _
"\\Fl-aejf-fs1\Data\Data\RECOVERY\EXLDATA\Loan Recovery MIS\" &
MyValue & "\Gross Placement Batch Tracks\AttorneyBatchTrack " & MyValue &
".xls"
Unload UserForm6
End If

If MyValue <= "2003_12" Then
Msg = "CAP publishing began with 2004_01. Please see a member of the
CAP "
Msg = Msg & "Team for reporting prior to that date"
Title = "Central Analytics"
Config = vbOK
End If


End Sub
 
C

Chip Pearson

Stephanie,

Try something like the following:


Dim M As Integer
Dim Y As Integer
Dim Pos As Integer
Dim S As String
Dim D As Date

S = InputBox("Enter date 'MM_YYYY'")
Pos = InStr(S, "_")
D = DateSerial(CInt(Mid(S, Pos + 1)), CInt(Left(S, 2)), 1)
If D >= DateSerial(2004, 1, 1) And D <= DateSerial(2004, 6, 30)
Then
MsgBox "Date OK"
Else
MsgBox "Invalid Date"
End If




--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




message
news:[email protected]...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top