#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Date error

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Date error

Greg,

You want a number not a date,

Sub Monthdate()
Dim celldt As Date
Dim TsMonth As Integer
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

--

HTH

RP
(remove nothere from the email address if mailing direct)


"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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Date error

Bob, thanks again, can't believe I missed that one.

Greg
"Bob Phillips" wrote in message
...
Greg,

You want a number not a date,

Sub Monthdate()
Dim celldt As Date
Dim TsMonth As Integer
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

--

HTH

RP
(remove nothere from the email address if mailing direct)


"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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Date error

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




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Date error

As Bob pointed out, in addition

Sub Monthdate()
Dim celldt As Date
Dim TsMonth As String
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

--
Regards,
Tom Ogilvy


"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








  #6   Report Post  
Posted to microsoft.public.excel.programming
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






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Date error

It converts the TsMonth variable to a long. I had assumed it was a string
and missed the fact you dim'd it as date.

--
Regards,
Tom Ogilvy

"GregR" wrote in message
...
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








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date error

Another option would be to forget about excel timesheets and use
Journyx, which is a free
program to do just about any kind of web timesheet tracking you could
ever think of.
http://journyx.com/clf/gendl.html

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Date error

There's also Projux (www.projux.com), which lets you gather your team's
project information online and optionally export it to Excel (as well
as PDF or XML) for custom analysis. Projux is fully web-hosted and is
perfect for small to mid-sized services firms. It can do time & expense
tracking, reporting and invoice generation instantly online.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Value Error Paula Excel Discussion (Misc queries) 6 February 9th 10 05:45 PM
date error hitesh New Users to Excel 1 September 4th 07 03:08 PM
date error hitesh via OfficeKB.com Excel Discussion (Misc queries) 1 October 20th 06 02:34 PM
Date Error - HELP! Mikey Moe Excel Discussion (Misc queries) 1 February 6th 05 02:43 AM
Date Error Murray N Taylor Excel Programming 4 January 16th 04 09:51 AM


All times are GMT +1. The time now is 09:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"