Date and time format issue

Posted on 2011-10-21
Last Modified: 2012-05-12
Hello all

I'm trying to add the date and time of the day in the same cell in this macro:
If Not r Is Nothing Then
  If r.Value > "" And r.Offset(, 28) = "" Then
    r.Offset(, 26).Value = Application.UserName
    r.Offset(, 27).NumberFormat = Date & " " & "[$-F400]h:mm AM/PM"
    r.Offset(, 27).Value = Date

  End If
End If

Open in new window

But the result in the cell is only: 21-10-2011.

How can i make it look like 21-10-2011  08:29 AM?

Thanks for your help
Question by:Wilder1626
    LVL 85

    Accepted Solution

    r.Offset(, 27).NumberFormat = "[$-F400]dd-mm-yyyy h:mm AM/PM"

    Open in new window

    LVL 85

    Expert Comment

    by:Rory Archibald
    Forgot the next line:
    r.Offset(, 27).Value = Now

    Open in new window

    LVL 11

    Author Closing Comment


    Thanks, it work

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    I've recently been in need of an Excel macro that could add a letter before the text on multiple cells in an Excel document. My English is as it is, so I will try explain what it does diffrently. If you have an excel document with 2000 rows an…
    Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
    Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
    The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now