将EXCEL表格中的数字字体全部修改为新罗马(Times New Roman)

EXCEL及VBA · 06-19
Sub 数字全部换为新罗马()
    Dim cell As Range
    Dim originalText As String
    Dim i As Long
    Dim char As String
    
    ' Loop through each selected cell
    For Each cell In Selection
        If Not IsEmpty(cell) Then
            originalText = cell.value
            If Len(originalText) > 0 Then
                ' Process each character in the cell
                For i = 1 To Len(originalText)
                    char = Mid(originalText, i, 1)
                    ' Check if the character is a digit
                    If IsNumeric(char) Then
                        ' Change font of numeric character to Times New Roman
                        cell.Characters(i, 1).Font.Name = "Times New Roman"
                    End If
                Next i
            End If
        End If
    Next cell
End Sub

VBA EXCEL