OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 441
- Office Version
- 2019
- Platform
- Windows
Thanks in advance for your assistance. I would like to format a cell in VBA with the time format. I wrote the code, but that doesn't work. Just something to start.
Some point outs.
Hours show up with two digits, but I do not want military time.
If I do not enter AM or PM, it defaults to AM automatically.
Example 1:
Entry: 4 AM
Result: 04:00 AM EST
Example 2:
Entry: 4 PM
Result: 04:00 PM EST
Example 3:
Entry: 4
Result: 04:00 AM EST
Some point outs.
Hours show up with two digits, but I do not want military time.
If I do not enter AM or PM, it defaults to AM automatically.
Example 1:
Entry: 4 AM
Result: 04:00 AM EST
Example 2:
Entry: 4 PM
Result: 04:00 PM EST
Example 3:
Entry: 4
Result: 04:00 AM EST
VBA Code:
Sub TimeFormatter()
For i = 1 to 100
Range("A" & i).NumberFormat = "HH:MM AM/PM EST"
End Sub