Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Cells Contents Anywhere Else in Column

Is there an easy way to see if the contents of any of the cells in a
column exist anywhere else in the column?

In words, I need to take the contents of a1 and compare it against all
the other cells in the column a. Then I want to take a2 and do the
same. Then a3 . . .

Thanks

-tom

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Cells Contents Anywhere Else in Column

you might consider sorting the column in order - then count instances of
each value. But if you wish to retain reference to where the duplicate
exists then you will need to run a loop. Do you need to know the first,
last or every instance of a duplicate, or just how many there are ?

--
Cheers
Nigel



"tom" wrote in message
oups.com...
Is there an easy way to see if the contents of any of the cells in a
column exist anywhere else in the column?

In words, I need to take the contents of a1 and compare it against all
the other cells in the column a. Then I want to take a2 and do the
same. Then a3 . . .

Thanks

-tom



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,560
Default Cells Contents Anywhere Else in Column

Seems the easiest way is to simply sort on the column. What do you want to do
it you find duplicates?
--
David


"tom" wrote:

Is there an easy way to see if the contents of any of the cells in a
column exist anywhere else in the column?

In words, I need to take the contents of a1 and compare it against all
the other cells in the column a. Then I want to take a2 and do the
same. Then a3 . . .

Thanks

-tom


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 279
Default Cells Contents Anywhere Else in Column

FIND

but code depends on what you want to do if it's not unique...
aircode
used twice Find will do the trick.
find this cell in range from row 1 this col to this cell offset-1,0
put this in a conditional format and turn red since it already showed up in
the col


find this cell in range from this cell offset 1,0 to xldown
put this in a conditional format and turn yellow since this is first
occurance but there are more

"tom" wrote:

Is there an easy way to see if the contents of any of the cells in a
column exist anywhere else in the column?

In words, I need to take the contents of a1 and compare it against all
the other cells in the column a. Then I want to take a2 and do the
same. Then a3 . . .

Thanks

-tom


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Cells Contents Anywhere Else in Column

you might consider sorting the column in order

Every instance, and which cells contain them. Sorting the column is
not an option - the column sort order is important to the layout of the
spreadsheet.

Thanks

-tom



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Cells Contents Anywhere Else in Column

Seems the easiest way is to simply sort on the column. What do you want to do
it you find duplicates?


Just print the cell numbers elsewhere on the worksheet, where there
will then be manual intervention.

-tom

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Cells Contents Anywhere Else in Column

Just wanted to share the final solutions - I played with the find
method of Range, but it just was not happening for me. While ugly, it
solved the problem.

Thanks to all.
------------
Sub checkContents()

Dim intRow As Integer
Dim cellString As String
Dim testString As String
Dim cellAddress As String

For Each cell In Range("k1", "k5072")
intRow = 5072
cellString = cell.Text
cellAddress = cell.Address

Do While intRow < Range(cellAddress).Row
testString = Cells(intRow, 11).Text
If testString = cellString Then
Cells(intRow, 12).Interior.ColorIndex = 46
Cells(intRow, 12).Value = cellAddress
End If
intRow = intRow - 1
Loop

Next cell

MsgBox "Done!"

End Sub
--------------

-tom

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 698
Default Cells Contents Anywhere Else in Column

Hi Tom,

As long as you are going to intervene manually you could use conditional
formatting. Select the column and enter this in the Formula Is in the
conditional formatting box and of course select a color. If you have
duplicates they will all light up except the last entry. So if you had
duplicated in A3, A35 A55 and A100 all except A100 will be highlighted. So
you would delete, or whatever, the 3, 35 55.

=COUNTIF(A1:A300,A1)1

HTH
Regards,
Howard

"tom" wrote in message
oups.com...
Is there an easy way to see if the contents of any of the cells in a
column exist anywhere else in the column?

In words, I need to take the contents of a1 and compare it against all
the other cells in the column a. Then I want to take a2 and do the
same. Then a3 . . .

Thanks

-tom



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Cells Contents Anywhere Else in Column

=COUNTIF(A1:A300,A1)1

Interesting. I am so Formula ignorant, and you have pointed out ways
in the past that formulas can solves problems without going to VBA.

I will play with this and see how it works.

Thanks for taking the time to respond.

-tom

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
concatenate contents of cells whose contents resemble cell referem cathyh Excel Worksheet Functions 3 May 23rd 09 12:16 PM
Displaying contents of differnt cells from a column in pages' head pmdoherty Excel Discussion (Misc queries) 0 May 14th 09 12:39 PM
Paste changing cell contents to consecutive cells in a column meggy Excel Worksheet Functions 3 September 4th 07 09:21 PM
Insert contents of various cells in a column into one cell? TextCells Excel Discussion (Misc queries) 1 April 2nd 06 10:41 PM
How do I change a buttons contents depending on a cells contents? Kosh42|EFG Excel Programming 2 February 16th 05 02:39 PM


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