Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default finding duplicates

Hello from Steved

I've 3 worksheets "20-Jun-08", "13-Jun-08", "06-Jun-08"

My question is please is that I've an employee numbers on all 3 worksheets

My Objective is if an employee number is on Sheet 20-Jun-2008 I would like
it to be highlighted in red if found on any of the other 2 worksheets. It may
appear on the other sheets several times but all is required it finds the
first instance ignore the rest.

So in Short find 1 only if found on other 2 worksheets

Thankyou.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default finding duplicates

I threw this together without testing, so you might have to tweak it.
If your employee numbers are not in column A, you will need to make
those changes in the code. It also assumes one header row.


Sub TurnRed()
Dim lr As Long, lr2 As Long, lr3 As Long
lr = Sheets("20-Jun-08").Cells(Rows.Count, 1).End(xlUp).Row
lr2 = Sheets("13-Jun-08").Cells(Rows.Count, 1).End(xlUp).Row
lr3 = Sheets("06-Jun-08").Cells(Rows.Count, 1).End(xlUp).Row
Set myRng = Sheets("20-Jun-08").Range("A2:A" & lr)
For Each c In myRng
Set fVal = Sheets("13-Jun-08").Range("A2:A" & lr2) _
.Find(c, LookIn:=xlValues)
If Not fVal Is Nothing Then
Sheets("20-Jun-08").Range(c.Address).Interior _
.ColorIndex = 3
Else
Set fVal = Sheets("06-Jun-08").Range("A2:A" & lr3) _
.Find(c, LookIn:=xlValues)
If Not fVal Is Nothing Then
Sheets("20-Jun-08").Range(c.Address).Interior _
.ColorIndex = 3
End If
End If
Next
End Sub





"Steved" wrote:

Hello from Steved

I've 3 worksheets "20-Jun-08", "13-Jun-08", "06-Jun-08"

My question is please is that I've an employee numbers on all 3 worksheets

My Objective is if an employee number is on Sheet 20-Jun-2008 I would like
it to be highlighted in red if found on any of the other 2 worksheets. It may
appear on the other sheets several times but all is required it finds the
first instance ignore the rest.

So in Short find 1 only if found on other 2 worksheets

Thankyou.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default finding duplicates

Hello from Steved

Thankyou.

"JLGWhiz" wrote:

I threw this together without testing, so you might have to tweak it.
If your employee numbers are not in column A, you will need to make
those changes in the code. It also assumes one header row.


Sub TurnRed()
Dim lr As Long, lr2 As Long, lr3 As Long
lr = Sheets("20-Jun-08").Cells(Rows.Count, 1).End(xlUp).Row
lr2 = Sheets("13-Jun-08").Cells(Rows.Count, 1).End(xlUp).Row
lr3 = Sheets("06-Jun-08").Cells(Rows.Count, 1).End(xlUp).Row
Set myRng = Sheets("20-Jun-08").Range("A2:A" & lr)
For Each c In myRng
Set fVal = Sheets("13-Jun-08").Range("A2:A" & lr2) _
.Find(c, LookIn:=xlValues)
If Not fVal Is Nothing Then
Sheets("20-Jun-08").Range(c.Address).Interior _
.ColorIndex = 3
Else
Set fVal = Sheets("06-Jun-08").Range("A2:A" & lr3) _
.Find(c, LookIn:=xlValues)
If Not fVal Is Nothing Then
Sheets("20-Jun-08").Range(c.Address).Interior _
.ColorIndex = 3
End If
End If
Next
End Sub





"Steved" wrote:

Hello from Steved

I've 3 worksheets "20-Jun-08", "13-Jun-08", "06-Jun-08"

My question is please is that I've an employee numbers on all 3 worksheets

My Objective is if an employee number is on Sheet 20-Jun-2008 I would like
it to be highlighted in red if found on any of the other 2 worksheets. It may
appear on the other sheets several times but all is required it finds the
first instance ignore the rest.

So in Short find 1 only if found on other 2 worksheets

Thankyou.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default finding duplicates

This should work for you. Assuming the Employees Names are all in Col. A on
each sheet.

Sub FindEmployee()

Dim LastRow20 As Long
Dim LastRow13 As Long
Dim LastRow6 As Long
Dim EmployeeRange As Range
Dim Range13 As Range
Dim Range6 As Range
Dim Employee As Range
Dim A As Variant
Dim B As Variant

Application.ScreenUpdating = False

LastRow20 = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set EmployeeRange = Sheets("Sheet1").Range(Cells(1, "A"),
Cells(LastRow20, "A"))

LastRow13 = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row
Set Range13 = Sheets("Sheet2").Range("A1:A" & LastRow13)

LastRow6 = Sheets("Sheet3").Cells(Rows.Count, "A").End(xlUp).Row
Set Range6 = Sheets("Sheet3").Range("A1:A" & LastRow6)


For Each Employee In EmployeeRange

Set A = Range13.Find(What:=Employee.Value, LookIn:=xlValues)
Set B = Range6.Find(What:=Employee.Value, LookIn:=xlValues)

If Not A Is Nothing Or Not B Is Nothing Then
Employee.Interior.ColorIndex = 3
End If

Next Employee

Application.ScreenUpdating = True

End Sub

Hope this helps! If it does please give credit.
--
Cheers,
Ryan


"Steved" wrote:

Hello from Steved

I've 3 worksheets "20-Jun-08", "13-Jun-08", "06-Jun-08"

My question is please is that I've an employee numbers on all 3 worksheets

My Objective is if an employee number is on Sheet 20-Jun-2008 I would like
it to be highlighted in red if found on any of the other 2 worksheets. It may
appear on the other sheets several times but all is required it finds the
first instance ignore the rest.

So in Short find 1 only if found on other 2 worksheets

Thankyou.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default finding duplicates

Hello RyanH

I thankyou

Steved

"RyanH" wrote:

This should work for you. Assuming the Employees Names are all in Col. A on
each sheet.

Sub FindEmployee()

Dim LastRow20 As Long
Dim LastRow13 As Long
Dim LastRow6 As Long
Dim EmployeeRange As Range
Dim Range13 As Range
Dim Range6 As Range
Dim Employee As Range
Dim A As Variant
Dim B As Variant

Application.ScreenUpdating = False

LastRow20 = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
Set EmployeeRange = Sheets("Sheet1").Range(Cells(1, "A"),
Cells(LastRow20, "A"))

LastRow13 = Sheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Row
Set Range13 = Sheets("Sheet2").Range("A1:A" & LastRow13)

LastRow6 = Sheets("Sheet3").Cells(Rows.Count, "A").End(xlUp).Row
Set Range6 = Sheets("Sheet3").Range("A1:A" & LastRow6)


For Each Employee In EmployeeRange

Set A = Range13.Find(What:=Employee.Value, LookIn:=xlValues)
Set B = Range6.Find(What:=Employee.Value, LookIn:=xlValues)

If Not A Is Nothing Or Not B Is Nothing Then
Employee.Interior.ColorIndex = 3
End If

Next Employee

Application.ScreenUpdating = True

End Sub

Hope this helps! If it does please give credit.
--
Cheers,
Ryan


"Steved" wrote:

Hello from Steved

I've 3 worksheets "20-Jun-08", "13-Jun-08", "06-Jun-08"

My question is please is that I've an employee numbers on all 3 worksheets

My Objective is if an employee number is on Sheet 20-Jun-2008 I would like
it to be highlighted in red if found on any of the other 2 worksheets. It may
appear on the other sheets several times but all is required it finds the
first instance ignore the rest.

So in Short find 1 only if found on other 2 worksheets

Thankyou.




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
Finding duplicates needitquick Excel Discussion (Misc queries) 3 June 11th 09 10:17 PM
Finding duplicates Stephanie Excel Discussion (Misc queries) 5 April 10th 07 09:10 AM
Finding Duplicates TLT Excel Worksheet Functions 2 February 23rd 06 04:06 PM
Finding duplicates Ted Metro Excel Worksheet Functions 2 November 21st 05 07:09 PM
finding duplicates?... Dan B Excel Programming 1 August 3rd 04 03:51 PM


All times are GMT +1. The time now is 05:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"