b9e5a2ff-1385-4ea5-8e84-cf5145be77格式完毕以后,请使用分列进行数据刷新
Sub ConvertToTimeFormat()
Dim LastRow As Long
Dim ws As Worksheet
Dim cellContent As String
' Assume we are working with the first (or active) worksheet
Set ws = ThisWorkbook.Sheets(1)
' Find the last row with data in column G
LastRow = ws.Cells(ws.Rows.Count, "G").End(xlUp).Row
' Loop through each row in column G
For i = 1 To LastRow
cellContent = ws.Cells(i, 7).Value
' Check if the cell content starts with a single quote
If Left(cellContent, 1) = "'" Then
' Remove the single quote and set the new value
ws.Cells(i, 7).Value = Right(cellContent, Len(cellContent) - 1)
End If
' Set the number format to "HH:MM"
ws.Cells(i, 7).NumberFormat = "hh:mm"
Next i
' 刷新单元格"
ws.Calculate
End Sub