Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DJS DJS is offline
external usenet poster
 
Posts: 31
Default compare strings - highlight characters which are different

Hello~
I need some assistance in writing a macro which could compare each
alpha-numeric character in each row of column I & J and hightlight (via font
color) the characters of column I which are different, then move to the next
row. I need to run the macro on every row until i come to a blank row.
Any help greatly appreciated.

Thanks in advance,
Don
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default compare strings - highlight characters which are different

Are the string lengths the same in both column I and J for each row?
DJS wrote:
Hello~
I need some assistance in writing a macro which could compare each
alpha-numeric character in each row of column I & J and hightlight (via font
color) the characters of column I which are different, then move to the next
row. I need to run the macro on every row until i come to a blank row.
Any help greatly appreciated.

Thanks in advance,
Don


  #3   Report Post  
Posted to microsoft.public.excel.programming
DJS DJS is offline
external usenet poster
 
Posts: 31
Default compare strings - highlight characters which are different

Yes, they should be 17 alpha-numeric characters.

"stevebriz" wrote:

Are the string lengths the same in both column I and J for each row?
DJS wrote:
Hello~
I need some assistance in writing a macro which could compare each
alpha-numeric character in each row of column I & J and hightlight (via font
color) the characters of column I which are different, then move to the next
row. I need to run the macro on every row until i come to a blank row.
Any help greatly appreciated.

Thanks in advance,
Don



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default compare strings - highlight characters which are different

DJS,
I don;t think it is possible to color characters with a different color
in the same cell.
so do you have another option?

DJS wrote:
Yes, they should be 17 alpha-numeric characters.

"stevebriz" wrote:

Are the string lengths the same in both column I and J for each row?
DJS wrote:
Hello~
I need some assistance in writing a macro which could compare each
alpha-numeric character in each row of column I & J and hightlight (via font
color) the characters of column I which are different, then move to the next
row. I need to run the macro on every row until i come to a blank row.
Any help greatly appreciated.

Thanks in advance,
Don




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default compare strings - highlight characters which are different

It's certainly possible to colour individual characters. The
following code will work on I1 and I2 as long as the values
are constant strings, not numbers or the results of formulas.

Option Explicit
Sub HighlightDifferences()
Dim r1 As Range, r2 As Range, i As Integer
Set r1 = Range("I1")
Set r2 = Range("J1")

For i = 1 To Len(r1.Value)
If Mid(r1.Value, i, 1) = Mid(r2.Value, i, 1) Then
r1.Characters(i, 1).Font.ColorIndex = xlAutomatic
Else
r1.Characters(i, 1).Font.Color = vbRed
End If
Next
End Sub





stevebriz wrote:
DJS,
I don;t think it is possible to color characters with a different color
in the same cell.
so do you have another option?

DJS wrote:
Yes, they should be 17 alpha-numeric characters.

"stevebriz" wrote:

Are the string lengths the same in both column I and J for each row?
DJS wrote:
Hello~
I need some assistance in writing a macro which could compare each
alpha-numeric character in each row of column I & J and hightlight (via font
color) the characters of column I which are different, then move to the next
row. I need to run the macro on every row until i come to a blank row.
Any help greatly appreciated.

Thanks in advance,
Don





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 195
Default compare strings - highlight characters which are different

This is great to know Andrew...thankyou for making me aware of this

  #7   Report Post  
Posted to microsoft.public.excel.programming
DJS DJS is offline
external usenet poster
 
Posts: 31
Default compare strings - highlight characters which are different

Thanks Andrew, I just added an "For Each, Next" loop to carry me through all
valid rows & a count of incorrect characters in an adjoining column and it
works great.
Much Appreciated!

"Andrew Taylor" wrote:

It's certainly possible to colour individual characters. The
following code will work on I1 and I2 as long as the values
are constant strings, not numbers or the results of formulas.

Option Explicit
Sub HighlightDifferences()
Dim r1 As Range, r2 As Range, i As Integer
Set r1 = Range("I1")
Set r2 = Range("J1")

For i = 1 To Len(r1.Value)
If Mid(r1.Value, i, 1) = Mid(r2.Value, i, 1) Then
r1.Characters(i, 1).Font.ColorIndex = xlAutomatic
Else
r1.Characters(i, 1).Font.Color = vbRed
End If
Next
End Sub





stevebriz wrote:
DJS,
I don;t think it is possible to color characters with a different color
in the same cell.
so do you have another option?

DJS wrote:
Yes, they should be 17 alpha-numeric characters.

"stevebriz" wrote:

Are the string lengths the same in both column I and J for each row?
DJS wrote:
Hello~
I need some assistance in writing a macro which could compare each
alpha-numeric character in each row of column I & J and hightlight (via font
color) the characters of column I which are different, then move to the next
row. I need to run the macro on every row until i come to a blank row.
Any help greatly appreciated.

Thanks in advance,
Don




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help: highlight all the same strings in one cell Cheng Excel Worksheet Functions 6 March 23rd 07 03:00 PM
Compare two strings andy62 Excel Worksheet Functions 8 September 6th 06 02:14 PM
Compare strings in cells and highlight difference Odin[_2_] Excel Programming 1 June 28th 06 10:14 AM
characters and strings elicamacho Excel Discussion (Misc queries) 4 March 20th 06 06:17 PM
Compare cells/columns and highlight matching text strings luxbelle Excel Worksheet Functions 1 February 25th 05 06:34 PM


All times are GMT +1. The time now is 06:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"