Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Date Value Error | Excel Discussion (Misc queries) | |||
date error | New Users to Excel | |||
date error | Excel Discussion (Misc queries) | |||
Date Error - HELP! | Excel Discussion (Misc queries) | |||
Date Error | Excel Programming |