A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
I posted using an old and unused profile above.
embry, again, you are pushing the good nature of the experts on this site to a limit that is becoming increasingly uncomfortable. We don't get paid to answer questions in these forums. We do it because we enjoy helping people. But there is only so much we can do. Try to keep your questions narrow and focused. Bound the problem as best you can. Describe the problem concisely, especially the inputs and outputs. There is absolutely nothing wrong with getting help on larger complex projects, but you have to be the project manager and reduce the challenges down to bite size chunks that can be answered in a few minutes.
As I stated before, here is a solution that solves your original problem, and the problem as you stated just now.
Here is a generic routine that does what you want to cells that contain a date time value in what we believe is the most raw format given some target range. This routine is aware of the format of the original raw value so it won't edit a cell that contains a value other than that. To use it, call it passing to it one cell, an entire column, or the whole worksheet. It will take every cell containing a date time value, convert it to a real date time value, subtract 8 hours, and place back into the cell the time only in 24 hour format and formatted as a text value to retain leading zeros.
For example, to process all values in column D as you are trying to do in your original routine:
Sub twenty_four_hour_Clock()
ConvertDateTime Range("D1", Range("D" & Rows.Count).End(xlUp))
End Sub
Here is the routine:
Sub ConvertDateTime(ByVal Target As Range)
Dim Cell As Range
Dim Value As Variant
Set Target = Intersect(Target, Target.Parent.UsedRange)
For Each Cell In Target.Cells
Value = Trim(Replace(CStr(Cell.Value), Chr(160), " "))
If Value Like "## [A-Za-z][A-Za-z][A-Za-z] #### ####" Then
Value = CDate(Left(Value, 11) & Space(1) & Mid(Value, 13, 2) & ":" & Mid(Value, 15, 2))
Value = Value - TimeSerial(8, 0, 0)
Cell.NumberFormat = "@"
Cell.Value = Format(Value, "HHMM")
End If
Next Cell
End Sub