Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Comparing formatting of two cells

Situation: Two cells contain the same text, and have the strikethrough format
applied to different subsets of the text.

Example:
Cell 1: THE QUICK BROWN FOX <start strikethrough JUMPED OVER <end
strkethrough THE LAZY DOG.
Cell 2: THE <start strikethrough QUICK BROWN <end strikethrough FOX
JUMPED OVER <end strkethrough THE LAZY DOG.

If the whole cell has the Strikethrough font attribute applied, then
Cell.Font.Strikethrough is True.
If none of it has the Strikethrough attribute applied, then
Cell.Font.Strikethrough is False.
If only some of it has the attribute applied, as in the examples above, then
Cells.Font.Strikethrough is Null.

Is there some way VBA can compare two cells formatted in the examples above
and identify that there is a difference between them?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Comparing formatting of two cells

Maybe like this:

Sub ChkCells()
Dim i As Integer
Dim Same As Boolean
Dim Cell1 As Range
Dim Cell2 As Range

Same = True
Set Cell1 = Range("A1") '<<Set as required
Set Cell2 = Range("A3") '<<Set as required

If Len(Cell1.Value) < Len(Cell2.Value) Or _
Cell1.Value < Cell2.Value Then
Same = False
Else
For i = 1 To Len(Cell1.Value)
If Cell1.Characters(i, 1).Font.Strikethrough < _
Cell2.Characters(i, 1).Font.Strikethrough Then
Same = False
Exit For
End If
Next i
End If
If Same Then
MsgBox "The cells have the same strikethrough"
Else
MsgBox "The cells have different strikethrough"
End If

End Sub

Hope this helps
Rowan

Chris B wrote:
Situation: Two cells contain the same text, and have the strikethrough format
applied to different subsets of the text.

Example:
Cell 1: THE QUICK BROWN FOX <start strikethrough JUMPED OVER <end
strkethrough THE LAZY DOG.
Cell 2: THE <start strikethrough QUICK BROWN <end strikethrough FOX
JUMPED OVER <end strkethrough THE LAZY DOG.

If the whole cell has the Strikethrough font attribute applied, then
Cell.Font.Strikethrough is True.
If none of it has the Strikethrough attribute applied, then
Cell.Font.Strikethrough is False.
If only some of it has the attribute applied, as in the examples above, then
Cells.Font.Strikethrough is Null.

Is there some way VBA can compare two cells formatted in the examples above
and identify that there is a difference between them?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Comparing formatting of two cells

Perfect! Thanks!

"Rowan Drummond" wrote:

Maybe like this:

Sub ChkCells()
Dim i As Integer
Dim Same As Boolean
Dim Cell1 As Range
Dim Cell2 As Range

Same = True
Set Cell1 = Range("A1") '<<Set as required
Set Cell2 = Range("A3") '<<Set as required

If Len(Cell1.Value) < Len(Cell2.Value) Or _
Cell1.Value < Cell2.Value Then
Same = False
Else
For i = 1 To Len(Cell1.Value)
If Cell1.Characters(i, 1).Font.Strikethrough < _
Cell2.Characters(i, 1).Font.Strikethrough Then
Same = False
Exit For
End If
Next i
End If
If Same Then
MsgBox "The cells have the same strikethrough"
Else
MsgBox "The cells have different strikethrough"
End If

End Sub

Hope this helps
Rowan

Chris B wrote:
Situation: Two cells contain the same text, and have the strikethrough format
applied to different subsets of the text.

Example:
Cell 1: THE QUICK BROWN FOX <start strikethrough JUMPED OVER <end
strkethrough THE LAZY DOG.
Cell 2: THE <start strikethrough QUICK BROWN <end strikethrough FOX
JUMPED OVER <end strkethrough THE LAZY DOG.

If the whole cell has the Strikethrough font attribute applied, then
Cell.Font.Strikethrough is True.
If none of it has the Strikethrough attribute applied, then
Cell.Font.Strikethrough is False.
If only some of it has the attribute applied, as in the examples above, then
Cells.Font.Strikethrough is Null.

Is there some way VBA can compare two cells formatted in the examples above
and identify that there is a difference between them?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 414
Default Comparing formatting of two cells

You're welcome.

Chris B wrote:
Perfect! Thanks!

"Rowan Drummond" wrote:


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
Comparing three columns, Conditional Formatting Marsh New Users to Excel 4 December 9th 09 09:58 PM
Conditional formatting comparing two columns Shelina Excel Worksheet Functions 6 November 5th 09 06:56 PM
Conditional formatting comparing times Mike Excel Worksheet Functions 14 February 17th 09 06:06 PM
Comparing two lists using Conditional Formatting [email protected] Excel Worksheet Functions 3 June 4th 07 01:10 PM
Conditional formatting/ comparing worksheets Excel Help! Excel Discussion (Misc queries) 0 January 10th 07 10:52 PM


All times are GMT +1. The time now is 11:50 PM.

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"