Unique ID using date & time

jts2004

Board Regular
Joined
Apr 21, 2004
Messages
156
I have a file save as macro that looks at a value in a cell that I create. I want that value to be YEARMONTHDAY MINUTES.

EX: 20051220 719 which means 12/20/2005 11:59AM

the problem in using the now() function is that you can't use "/" or ":" when saving a file. so the cell value has to equal "20051220 719" in order for the macro to save the file.
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Assuming your date and time is in A1 on Sheet1:

Code:
Sub Test()
    With Worksheets("Sheet1").Range("A1")
        MsgBox Format(.Value, "yyyymmdd") & " " & WorksheetFunction.Round((.Value - Int(.Value)) * 1440, 0)
    End With
End Sub
 
Upvote 0
Re: THANKS

jts2004 said:
Any way to do it with a formula in A1

A formula in A1 referring to what? If the date and time were in B1:

=TEXT(B1,"yyyymmdd")&" "&ROUND((B1-INT(B1))*1440,0)
 
Upvote 0

Forum statistics

Threads
1,215,065
Messages
6,122,945
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top