How to get all red text from excel cell in vba string in a HTML format
Private Sub CommandButton1_Click()
Dim val As String
val = Cells(5, "G").Value
Dim fast As Boolean
fast = True
Dim last As Boolean
last = False
Dim values As String
values = ""
Dim lent As Integer
lent = Len(val)
Dim result As String
result = ""
For i = 1 To lent
If Cells(5, "G").Characters(Start:=i, Length:=1).Font.Color = vbRed Then
If fast Then
values = "<span style='color:#dd0062;'>" & "" & Mid(val, i, 1)
fast = False
last = True
Else
last = True
values = values & "" & Mid(val, i, 1)
End If
Else
If last Then
values = values & "</span>" & Mid(val, i, 1)
last = False
fast = True
result = result & "" & values
values = "<span style='color:#dd0062;'>"
Else
result = result & "" & Mid(val, i, 1)
End If
End If
Next i
MsgBox (result)
End Sub
Dim val As String
val = Cells(5, "G").Value
Dim fast As Boolean
fast = True
Dim last As Boolean
last = False
Dim values As String
values = ""
Dim lent As Integer
lent = Len(val)
Dim result As String
result = ""
For i = 1 To lent
If Cells(5, "G").Characters(Start:=i, Length:=1).Font.Color = vbRed Then
If fast Then
values = "<span style='color:#dd0062;'>" & "" & Mid(val, i, 1)
fast = False
last = True
Else
last = True
values = values & "" & Mid(val, i, 1)
End If
Else
If last Then
values = values & "</span>" & Mid(val, i, 1)
last = False
fast = True
result = result & "" & values
values = "<span style='color:#dd0062;'>"
Else
result = result & "" & Mid(val, i, 1)
End If
End If
Next i
MsgBox (result)
End Sub
Comments
Post a Comment