Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
comapring cell values
Hi, i have a list on a worksheet (sheet1) which looks like this for
example. the list is in alphabetical order so any indentical cells are next to each other. AA AA AB AB AC AC AD AG AL AM AM i am trying to write a macro which will go through each cell and compare it with the next cell. if they are the same the second cell's value is changed to an "*". i tried a couple of ways but everytime i just crash excel. the list would look like this after the macro was run. AA * AB * AC * AD AG AL AM * thanks in advance. nick |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
comapring cell values
Sub test()
Dim iLastRow As Long Dim i As Long iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = iLastRow To 2 Step -1 If Cells(i,"A").Value = Cells(i-1,"A").Value Then Cells(i,"A").Value = "*" End If Next i End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "nickm687" wrote in message ups.com... Hi, i have a list on a worksheet (sheet1) which looks like this for example. the list is in alphabetical order so any indentical cells are next to each other. AA AA AB AB AC AC AD AG AL AM AM i am trying to write a macro which will go through each cell and compare it with the next cell. if they are the same the second cell's value is changed to an "*". i tried a couple of ways but everytime i just crash excel. the list would look like this after the macro was run. AA * AB * AC * AD AG AL AM * thanks in advance. nick |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
comapring cell values
ha works a treat. and you make it look simple.
thank you very much. Bob Phillips wrote: Sub test() Dim iLastRow As Long Dim i As Long iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = iLastRow To 2 Step -1 If Cells(i,"A").Value = Cells(i-1,"A").Value Then Cells(i,"A").Value = "*" End If Next i End Sub -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "nickm687" wrote in message ups.com... Hi, i have a list on a worksheet (sheet1) which looks like this for example. the list is in alphabetical order so any indentical cells are next to each other. AA AA AB AB AC AC AD AG AL AM AM i am trying to write a macro which will go through each cell and compare it with the next cell. if they are the same the second cell's value is changed to an "*". i tried a couple of ways but everytime i just crash excel. the list would look like this after the macro was run. AA * AB * AC * AD AG AL AM * thanks in advance. nick |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Copy values from a cell based on values of another cell | Excel Discussion (Misc queries) | |||
How to assign values to a cell based on values in another cell? | Excel Worksheet Functions | |||
Comapring fields that have TXT and No's | Excel Worksheet Functions | |||
Search/Filter to find values in another range based on two cell values | Excel Programming |