Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default 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
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
Copy values from a cell based on values of another cell Spence10169 Excel Discussion (Misc queries) 4 January 13th 09 10:01 AM
How to assign values to a cell based on values in another cell? Joao Lopes Excel Worksheet Functions 1 December 5th 07 09:02 PM
Comapring fields that have TXT and No's Alisdair Excel Worksheet Functions 4 April 11th 06 05:17 PM
Search/Filter to find values in another range based on two cell values Andy Excel Programming 2 April 29th 04 04:08 PM


All times are GMT +1. The time now is 09:49 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"