Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Colour cells with dupilate numbers

Is it possible to have a column of numbers and as I enter
new numbers to the column the cell changes colour if the
number already appears in the column.

Column

100052
100053
100098
100032


New number entered

100056 - No colour change

100053 - Cell colour changed


Many Thanks

Simon
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Colour cells with dupilate numbers

The folowing may get you going.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False

Dim Rw, Col, X
Rw = Target.Row: Col = Target.Column
For X = 1 To Rw - 1
If Cells(X, 1) = Target Then
Cells(Rw, 1).Font.ColorIndex = 3
End If
Next

Application.EnableEvents = True
End Sub

Assuming that the data is all in column 1 (A), duplicated entries will be
coloured RED.

regards,

don
--

"Simon" wrote in message
...
Is it possible to have a column of numbers and as I enter
new numbers to the column the cell changes colour if the
number already appears in the column.

Column

100052
100053
100098
100032


New number entered

100056 - No colour change

100053 - Cell colour changed


Many Thanks

Simon



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default Colour cells with dupilate numbers

"Don Lloyd" wrote in message ...
The folowing may get you going.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False

Dim Rw, Col, X
Rw = Target.Row: Col = Target.Column
For X = 1 To Rw - 1
If Cells(X, 1) = Target Then
Cells(Rw, 1).Font.ColorIndex = 3
End If
Next

Application.EnableEvents = True
End Sub

Assuming that the data is all in column 1 (A), duplicated entries will be
coloured RED.


As a variation (which is proably far from foolproof!):
Put this declaration at the top of the worksheet code module
Dim NumberList As New Collection

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Application.EnableEvents = False
On Error Resume Next
With Target
NumberList.Add .Text, .Text
'error generated if number already exists
If Err.Number < 0 Then
.Interior.ColorIndex = 3
End If
End With
On Error GoTo 0
Application.EnableEvents = True
End Sub

This will work where ever you put the numbers on the sheet
regards
Paul
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
colour numbers jkf[_3_] Excel Worksheet Functions 2 March 25th 11 10:08 PM
colour cells, same numbers different worksheets geenie Excel Worksheet Functions 1 January 23rd 10 01:38 PM
Changing all cells in one colour to a different colour Bob Excel Discussion (Misc queries) 3 June 25th 08 02:12 PM
Help Please.....numbers reaching limits and cells changing colour mgoo Excel Worksheet Functions 3 April 7th 08 01:43 PM
Adding numbers in cells based on colour Draccusfly Excel Worksheet Functions 1 September 1st 06 04:05 PM


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