Coloring part of the text in a cell
Solved
July74
Posted messages
49
Status
Membre
-
July74 Posted messages 49 Status Membre -
July74 Posted messages 49 Status Membre -
Hello,
I have several data points in a column, some of which end with "-X"
I would like all these "-X" to be changed to white.
For example:
8801
8812
8815-X
8817
8820-X
Only change the text color of the "-X".
This is probably very simple, but I'm having trouble.
Thank you for your help.
Configuration: Windows 7 / Mozilla 11.0
I have several data points in a column, some of which end with "-X"
I would like all these "-X" to be changed to white.
For example:
8801
8812
8815-X
8817
8820-X
Only change the text color of the "-X".
This is probably very simple, but I'm having trouble.
Thank you for your help.
Configuration: Windows 7 / Mozilla 11.0
3 réponses
Thank you for the responses
I am very late on the subject, I had to close this file temporarily.
Here's in response to via55
I cannot delete them.
And my question was to make the operation automatic.
I actually found my answer and I'm sharing it in case someone else is looking for something similar;
Sub Treatment()
Dim Range As Range, Cell As Range
Dim TheWord As String, StartAddr As String
Set Range = Sheets("JOB LIST").Range("A:A")
TheWord = "-X"
With Range
Set Cell = .Find(TheWord, LookAt:=xlPart)
If Not Cell Is Nothing Then
StartAddr = Cell.Address
Do
Modify Cell, TheWord
Set Cell = .FindNext(Cell)
Loop While Not Cell Is Nothing And StartAddr <> Cell.Address
End If
End With
End Sub
Private Sub Modify(ByRef Cell As Range, TheWord)
Dim T As String
Dim Pos As Integer
T = Cell.Text
Do
Pos = InStr(Pos + 1, T, TheWord)
If Pos > 0 Then
With Cell.Characters(Start:=Pos, Length:=Len(TheWord)).Font
.FontStyle = "Bold"
.ColorIndex = 2 'white
End With
End If
Loop Until Pos = 0
End Sub
There you go!
I am very late on the subject, I had to close this file temporarily.
Here's in response to via55
I cannot delete them.
And my question was to make the operation automatic.
I actually found my answer and I'm sharing it in case someone else is looking for something similar;
Sub Treatment()
Dim Range As Range, Cell As Range
Dim TheWord As String, StartAddr As String
Set Range = Sheets("JOB LIST").Range("A:A")
TheWord = "-X"
With Range
Set Cell = .Find(TheWord, LookAt:=xlPart)
If Not Cell Is Nothing Then
StartAddr = Cell.Address
Do
Modify Cell, TheWord
Set Cell = .FindNext(Cell)
Loop While Not Cell Is Nothing And StartAddr <> Cell.Address
End If
End With
End Sub
Private Sub Modify(ByRef Cell As Range, TheWord)
Dim T As String
Dim Pos As Integer
T = Cell.Text
Do
Pos = InStr(Pos + 1, T, TheWord)
If Pos > 0 Then
With Cell.Characters(Start:=Pos, Length:=Len(TheWord)).Font
.FontStyle = "Bold"
.ColorIndex = 2 'white
End With
End If
Loop Until Pos = 0
End Sub
There you go!
Good evening
To do it manually, you need to go into each cell, highlight the -X in the formula bar, and select white text
To do it automatically, you need to create a macro to do it
But why not simply delete them? By using CTRL + H, put -X in Find, leave nothing in Replace, and Replace all
Best regards
--
"Imagination is more important than knowledge." A. Einstein
To do it manually, you need to go into each cell, highlight the -X in the formula bar, and select white text
To do it automatically, you need to create a macro to do it
But why not simply delete them? By using CTRL + H, put -X in Find, leave nothing in Replace, and Replace all
Best regards
--
"Imagination is more important than knowledge." A. Einstein