Thread: Date error
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
GregR[_2_] GregR[_2_] is offline
external usenet poster
 
Posts: 6
Default Date error

Tom, just curious, what is the "clng" in the dateSerial alternative. TIA

Greg
"Tom Ogilvy" wrote in message
...
Sub Monthdate()
Dim celldt As Date
Dim TsMonth As Date
TsMonth = InputBox("Enter month number for timesheet, such as (1) for

Jan",
"Timesheet Month...", 1)
celldt = DateValue(TsMonth & "/1/2005")
Range("S2").Value = celldt
End Sub

or
celldt = DateSerial(2005,clng(TsMonth),1)

--
Regards,
Tom Ogilvy

"GregR" wrote in message
...
I have the following sub which errors:
Sub Monthdate()
Dim celldt As Date
Dim TsMonth As Date
TsMonth = InputBox("Enter month number for timesheet, such as (1) for

Jan",
"Timesheet Month...", 1)
celldt = TsMonth & "/1/2005" Error on this line
Range("S2").Value = celldt
End Sub

I want cell S2 to display the first date of the month specified in the

input
box. TIA

Greg