I am having a problems in with relation to time formats and would greatly appreciate any help.
The excel file I am writing the code for uses a Userform to prompt the user to select a file with various data - .txt format. I have to use the delimited options to preserve all the required data in separate cells (i.e. I can't paste into clipboard and then bring it into Excel as text). The problem is that the source program for the .txt file (which I have no control over) puts time into this format: 456:42:00 (example).
This represents 04:56:42 in UTC / 24hr time. The time is correct as displayed, but I need to reference the time in other subs to compare the times between multiple lines. When I try to use any time or time/date based formula ("Hours()", "Minutes()" , "Seconds()" , "DateDiff() ", etc...) it reads the spot with "456" (sometimes 4 digits depending on the time) as hours (although it is actually both hours and minutes), the spot with "42" as minutes (which is actually seconds) and finally the spot with "00" as seconds, which is actually 'spoofer' info. Again, throw all the sarcastic comments you want at the format the time is spit out in, but that is the file format I need to work with.
I've tried the following:
Setting the .numberformat to "hh:mm:ss" or "[h]:mm:ss"
Setting .value = "=left()", as well as the Mid, and Right formulas
All of these just corrupts the time, since it doesn't see the hours, minutes and seconds in the right spot.
I also tried setting .text instead of .value with the left/right and mid, but get and "Object Required" error.
Any help? I tried to make it a textual explanation since the coding gets complicated.
The excel file I am writing the code for uses a Userform to prompt the user to select a file with various data - .txt format. I have to use the delimited options to preserve all the required data in separate cells (i.e. I can't paste into clipboard and then bring it into Excel as text). The problem is that the source program for the .txt file (which I have no control over) puts time into this format: 456:42:00 (example).
This represents 04:56:42 in UTC / 24hr time. The time is correct as displayed, but I need to reference the time in other subs to compare the times between multiple lines. When I try to use any time or time/date based formula ("Hours()", "Minutes()" , "Seconds()" , "DateDiff() ", etc...) it reads the spot with "456" (sometimes 4 digits depending on the time) as hours (although it is actually both hours and minutes), the spot with "42" as minutes (which is actually seconds) and finally the spot with "00" as seconds, which is actually 'spoofer' info. Again, throw all the sarcastic comments you want at the format the time is spit out in, but that is the file format I need to work with.
I've tried the following:
Setting the .numberformat to "hh:mm:ss" or "[h]:mm:ss"
Setting .value = "=left()", as well as the Mid, and Right formulas
All of these just corrupts the time, since it doesn't see the hours, minutes and seconds in the right spot.
I also tried setting .text instead of .value with the left/right and mid, but get and "Object Required" error.
Any help? I tried to make it a textual explanation since the coding gets complicated.
Comment