+ Reply to Thread
Results 1 to 9 of 9

Date error

  1. #1
    GregR
    Guest

    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. #2
    Bob Phillips
    Guest

    Re: 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" <gregrivet@hotmail.com> wrote in message
    news:O2ymyHBAFHA.3820@TK2MSFTNGP11.phx.gbl...
    > 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. #3
    GregR
    Guest

    Re: Date error

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

    Greg
    "Bob Phillips" <bob.phillips@notheretiscali.co.uk> wrote in message
    news:uZThLNBAFHA.4028@TK2MSFTNGP15.phx.gbl...
    > 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" <gregrivet@hotmail.com> wrote in message
    > news:O2ymyHBAFHA.3820@TK2MSFTNGP11.phx.gbl...
    > > 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. #4
    Tom Ogilvy
    Guest

    Re: 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" <gregrivet@hotmail.com> wrote in message
    news:O2ymyHBAFHA.3820@TK2MSFTNGP11.phx.gbl...
    > 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. #5
    Tom Ogilvy
    Guest

    Re: 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" <twogilvy@msn.com> wrote in message
    news:ePbFARBAFHA.3528@tk2msftngp13.phx.gbl...
    > 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" <gregrivet@hotmail.com> wrote in message
    > news:O2ymyHBAFHA.3820@TK2MSFTNGP11.phx.gbl...
    > > 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. #6
    GregR
    Guest

    Re: Date error

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

    Greg
    "Tom Ogilvy" <twogilvy@msn.com> wrote in message
    news:ePbFARBAFHA.3528@tk2msftngp13.phx.gbl...
    > 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" <gregrivet@hotmail.com> wrote in message
    > news:O2ymyHBAFHA.3820@TK2MSFTNGP11.phx.gbl...
    > > 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. #7
    Tom Ogilvy
    Guest

    Re: 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" <gregrivet@hotmail.com> wrote in message
    news:uxkKNaBAFHA.1084@tk2msftngp13.phx.gbl...
    > Tom, just curious, what is the "clng" in the dateSerial alternative. TIA
    >
    > Greg
    > "Tom Ogilvy" <twogilvy@msn.com> wrote in message
    > news:ePbFARBAFHA.3528@tk2msftngp13.phx.gbl...
    > > 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" <gregrivet@hotmail.com> wrote in message
    > > news:O2ymyHBAFHA.3820@TK2MSFTNGP11.phx.gbl...
    > > > 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. #8
    Curt Finch
    Guest

    Re: 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. #9
    sales@projux.com
    Guest

    Re: 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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1