Solved

Date and time format issue

Posted on 2011-10-21
Medium Priority
171 Views
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(, 27).NumberFormat = Date & " " & "[\$-F400]h:mm AM/PM"
r.Offset(, 27).Value = Date

End If
End If
``````

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

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

0
Question by:Wilder1626
• 2

LVL 85

Accepted Solution

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

LVL 85

Expert Comment

ID: 37005937
Forgot the next line:
``````r.Offset(, 27).Value = Now
``````
0

LVL 11

Author Closing Comment

ID: 37006040
perfect.

Thanks, it work
0

Featured Post

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â€¦
Suggested Courses
Course of the Month14 days, 22 hours left to enroll