?
Solved

Date and time format issue

Posted on 2011-10-21
3
Medium Priority
?
171 Views
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
0
Comment
Question by:Wilder1626
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 2000 total points
ID: 37005936
Try:
r.Offset(, 27).NumberFormat = "[$-F400]dd-mm-yyyy h:mm AM/PM"

Open in new window

0
 
LVL 85

Expert Comment

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

Open in new window

0
 
LVL 11

Author Closing Comment

by:Wilder1626
ID: 37006040
perfect.

Thanks, it work
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

840 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