tezza
Active Member
- Joined
- Sep 10, 2006
- Messages
- 398
- Office Version
- 365
- Platform
- Windows
- Web
Hi all,
I got this report that comes from an external software which is showing time as text in a 12 hour format, eg: 04:30 PM
I can add a formula to change it so that it works = TimeValue(C2)
How do I do this in VBA:
In a formula this works, but other people use it that would likely mess it up, so I'll run it as a macro.
EG:
I got this report that comes from an external software which is showing time as text in a 12 hour format, eg: 04:30 PM
I can add a formula to change it so that it works = TimeValue(C2)
How do I do this in VBA:
- Insert Col at Col D
- Cell D1 = Time
- Cells D2 down = TimeValue(C2) if C2 isn't blank (drag down until it gets to the bottom row
- Change Range Col D2 down to Time Format [hh]:mm
In a formula this works, but other people use it that would likely mess it up, so I'll run it as a macro.
Excel Formula:
IF(C2="","",TIMEVALUE(C2))
EG:
Staff_Mileage (2).xlsx | ||||
---|---|---|---|---|
C | D | |||
1 | Start Time | Time | ||
2 | ||||
3 | ||||
4 | ||||
5 | ||||
6 | ||||
7 | ||||
8 | 08:25 AM | 08:25 | ||
9 | ||||
10 | ||||
11 | 09:00 AM | 09:00 | ||
12 | 09:00 AM | 09:00 | ||
13 | ||||
14 | ||||
15 | 04:30 PM | 16:30 | ||
Staff_Mileage |
Cell Formulas | ||
---|---|---|
Range | Formula | |
D2:D15 | D2 | =IF(C2="","",TIMEVALUE(C2)) |