|
Public Function HexToString(ByVal HexToStr As String) As String
Dim strTemp As String
Dim strReturn As String
Dim I As Long
For I = 1 To Len(HexToStr) Step 2 'edit: 2 instead of 3
strTemp = Chr$(Val("&H" & Mid$(HexToStr, I, 2)))
strReturn = strReturn & strTemp
Next I
HexToString = Right(strReturn, Len(strReturn) - 1) 'edit: removes first character (else printed value is empty)
End Function
Sub TranslateAllHex()
Dim aCell As Range
Dim aCellsValue As String
Dim OutputString As String
For Each aCell In Selection
aCellsValue = aCell.Value
If Not aCellsValue = "" Then
If Left(aCellsValue, 2) = "0x" Then
aCell.Value = HexToString(aCell.Value)
End If
End If
Next aCell
End Sub
|
|