+ Reply to Thread
Results 1 to 3 of 3

Adding date and time to same cell

  1. #1
    Registered User
    Join Date
    03-21-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Adding date and time to same cell

    Hello:
    I've created a user form which among other things has DTPicker1 and DTPicker2.
    DTP1 is for the date and DTP2 for the time.
    When adding the information to the spread sheet, I'd like the date and time to appear in the same cell - so they look like this:
    21/03/2013 09:30
    , but am not sure how to go about this.
    Currently my code is similar to this:

    Private Sub cmdAdd_Click()
    ActiveWorkbook.Sheets("Workflow").Activate
    Range("A1").Select

    Do

    If IsEmpty(ActiveCell) = False Then
    ActiveCell.Offset(1, 0).Select
    End If

    Loop Until IsEmpty(ActiveCell) = True

    ActiveCell.Value = txtAgmt.Value
    ActiveCell.Offset(0, 1) = txtID.Value
    ActiveCell.Offset(0, 2) = txtPartner.Value
    ActiveCell.Offset(0, 3) = txtDeal.Value
    ActiveCell.Offset(0, 4) = txtTerritory.Value
    ActiveCell.Offset(0, 5) = DTPicker1.Value
    ActiveCell.Offset(0, 6) = DTPicker2.Value
    ActiveCell.Offset(0, 7) = txtDraftTime.Value
    ActiveCell.Offset(0, 8) = txtAddTime.Value
    ActiveCell.Offset(0, 9) = cboInstructor.Value
    ActiveCell.Offset(0, 10) = cboTask.Value

    Range("A1").Select

    Response = MsgBox("Would you like to add another entry?", _
    vbQuestion + vbYesNo)

    If Reponse = vbNo Then Exit Sub

    Call UserForm_Initialize

    End Sub


    Any suggestions or comments gladly appreciated.

  2. #2
    Valued Forum Contributor Sean Thomas's Avatar
    Join Date
    03-25-2012
    Location
    HerneBay, Kent, UK
    MS-Off Ver
    Excel 2007,2016
    Posts
    971

    Re: Adding date and time to same cell

    ActiveCell.Offset(0, 5) = DTPicker1.Value & " " & DTPicker2.Value
    Regards
    Sean

    Please add to my reputation if you think i helped
    (click on the star below the post)
    Mark threads as "Solved" if you have your answer
    (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code:
    [code] Your code here [code]
    Please supply a workbook containing example Data:
    It makes its easier to answer your problem & saves time!

  3. #3
    Registered User
    Join Date
    03-21-2013
    Location
    London, UK
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Adding date and time to same cell

    Thank you very much, don't know why I couldn't see the wood for the trees! But you've saved me from sitting and puzzling - always a good thing.

+ 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