View Full Version : Change color of numeric characters
swaggerbox
03-14-2018, 11:57 PM
Is there a way to automatically change the font color of numeric characters in: 1) cell and 2) richtextbox. For example, using the string "I have 3 hands", the "3" should be in RED font while the rest in blank. Is there a way to do that using VBA?
mancubus
03-15-2018, 04:21 AM
this is for text in a cell:
Sub chg_num_char_col()
Dim i As Long
For i = 1 To Len(Range("A1").Value)
If IsNumeric(Mid(Range("A1").Value, i, 1)) = True Then
Range("A1").Characters(i, 1).Font.Color = vbRed
End If
Next
End Sub
for richtextbox see below and many other sites which google will offer. :)
https://stackoverflow.com/questions/39051237/insert-richtextbox-in-userform-excelvba
from here:
https://www.experts-exchange.com/questions/26147999/How-to-add-a-RichTextBox-Control-for-a-VBA-Application-for-Microsoft-Word.html
http://www.vbforums.com/showthread.php?666655-changing-a-color-for-specific-string-in-text-box
https://msdn.microsoft.com/en-us/library/aa733519(v=vs.60).aspx
swaggerbox
03-20-2018, 11:32 PM
Thank you Mancubus!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.