Greetings,
I have a situation where I have Data in Col F (singular data entry ex: 24681) and I need to compare to col G where there is a string of numbers. Ex: 12345, 45654, 66531, 24681
I need to compare and if found, highlight JUST that exact string found in the cell.
VBA is perferred.
Thanks,
Brad
Compare on cell to another, and highlight data if found
-
- 4StarLounger
- Posts: 538
- Joined: 30 Mar 2010, 18:49
- Location: United States
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Compare on cell to another, and highlight data if found
Is this about a single cell in column F or multiple cells?
And is this about a single cell in column G or multiple cells?
Perhaps you could attach a small sample workbook.
And is this about a single cell in column G or multiple cells?
Perhaps you could attach a small sample workbook.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 538
- Joined: 30 Mar 2010, 18:49
- Location: United States
Re: Compare on cell to another, and highlight data if found
as requested.
Range is variable.
Range is variable.
-
- 4StarLounger
- Posts: 538
- Joined: 30 Mar 2010, 18:49
- Location: United States
Re: Compare on cell to another, and highlight data if found
trying again
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Compare on cell to another, and highlight data if found
See the attached version.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 538
- Joined: 30 Mar 2010, 18:49
- Location: United States
Re: Compare on cell to another, and highlight data if found
Sweet. I like the results!
-
- 4StarLounger
- Posts: 538
- Joined: 30 Mar 2010, 18:49
- Location: United States
Re: Compare on cell to another, and highlight data if found
Additionally, I have tried to add .Font.Bold = true, to this but am not being successful. How do I get this line to make it Bold?
Range("P" & r).Characters(Start:=p, Length:=n).Font.Color = vbRed & .Font.Bold = True
Range("P" & r).Characters(Start:=p, Length:=n).Font.Color = vbRed & .Font.Bold = True
-
- Administrator
- Posts: 78545
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Compare on cell to another, and highlight data if found
Like this:
Code: Select all
Sub RemoveColor()
With Range("G:G").Font
.ColorIndex = xlColorIndexAutomatic
.Bold = False
End With
End Sub
Sub ColorEntries()
Dim r As Long
Dim m As Long
Dim s As String
Dim n As Long
Dim p As Long
Application.ScreenUpdating = False
RemoveColor
m = Range("G" & Rows.Count).End(xlUp).Row
For r = 2 To m
s = Range("F" & r).Text
n = Len(s)
p = InStr(Range("G" & r).Value, s)
If p > 0 Then
With Range("G" & r).Characters(Start:=p, Length:=n).Font
.Color = vbRed
.Bold = True
End With
End If
Next r
Application.ScreenUpdating = True
End Sub
Best wishes,
Hans
Hans
-
- 4StarLounger
- Posts: 538
- Joined: 30 Mar 2010, 18:49
- Location: United States
Re: Compare on cell to another, and highlight data if found
As always, I learn something!!
Thanks,
Brad
Thanks,
Brad