View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Gerencsér Gábor Gerencsér Gábor is offline
external usenet poster
 
Posts: 19
Default Matching contents of a cell full of text

I suggest to try the following:

Sub CompareCells()
'Please note this macro assumes the entries are continuous.
'(Means there are no empty cells in between.)
Range("A1").Select 'This is your starting cell.
'Please edit cell address to fit your needs.
Do Until ActiveCell = Empty
If ActiveCell Like ActiveCell(0, 1) Then _
ActiveCell.Offset(0, 5).FormulaR1C1 = "Identical"
'Edit the offset as it fits your sheet.
Else
ActiveCell.Offset(0, 5).FormulaR1C1 = "Different"
End If
ActiveCell.Offset(1, 0).Select
Loop
End Sub



"brien downie" az alábbiakat írta a következo
hírüzenetben: ...
I'm trying to write a macro that will compare the contents of two
nearby cells to see if they are identical. The cells all contain the
names of creative placements, so they are not numerical values.

I'm thinking something like,

sub test

if activecell.offset(5, -1) = activecell.offset(5,-2) then
Msgbox("These are the same")
' And then do any action I want
Else
Msgbox("These are not the same")
End if
End sub

does anybody know how to effectively do that first If statement?

Thanks,
-Brien