Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
KCG KCG is offline
external usenet poster
 
Posts: 20
Default VBA Code macro for duplicate entries

Hello friends,

I have my data in the range J14:AA14.

Please help me to create a VBA macro which will find duplicate entries in
this range and colour both cells red.

Thanx

--
KCG
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default VBA Code macro for duplicate entries

Select your range and run:

Sub DupFinder()
Dim r As Range, t As Range
Set t = Selection
For Each r In t
v = r.Value
If Application.WorksheetFunction.CountIf(t, v) 1 Then
r.Interior.ColorIndex = 3
End If
Next
End Sub

This is a general routine based on Selection. If you don't want to have to
Select then replace:

Set t = Selection
with:
Set t = Range("J14:AA14")
--
Gary''s Student - gsnu200781


"KCG" wrote:

Hello friends,

I have my data in the range J14:AA14.

Please help me to create a VBA macro which will find duplicate entries in
this range and colour both cells red.

Thanx

--
KCG

  #3   Report Post  
Posted to microsoft.public.excel.misc
KCG KCG is offline
external usenet poster
 
Posts: 20
Default VBA Code macro for duplicate entries

Hello Gary's Student,

I tried your suggestion and it worked fine. I have now changed the range to
J14:AA16.

I also have the following macro which I would like to merge with your
suggestion.
(This macro 'kicks in' every 16 rows automatically when I run it):

Public Sub ProcessData(StartRow)

For i = 10 To 14
For j = (StartRow + 1) To (StartRow + 1)
For k = 10 To 27
For L = (StartRow + 2) To (StartRow + 15)
If Cells(j, i).Value = Cells(L, k).Value Then
Cells(L, k).Font.ColorIndex = 38
End If
Next
Next
Next
Next

End Sub
--------------------------------------------------------------------------------------
Public Sub ProcessFile()
sectionRows = 16
startRows = 3
startCheckRow = 4
canContinue = (Cells(startCheckRow, 2).Value 0)

While canContinue
ProcessData (startRows)
startRows = startRows + sectionRows
startCheckRow = startCheckRow + sectionRows
canContinue = (Cells(startCheckRow, 2).Value 0)
Wend
End Sub


How do I merge the two macros? Thanx for your help.

--
KCG


"Gary''s Student" wrote:

Select your range and run:

Sub DupFinder()
Dim r As Range, t As Range
Set t = Selection
For Each r In t
v = r.Value
If Application.WorksheetFunction.CountIf(t, v) 1 Then
r.Interior.ColorIndex = 3
End If
Next
End Sub

This is a general routine based on Selection. If you don't want to have to
Select then replace:

Set t = Selection
with:
Set t = Range("J14:AA14")
--
Gary''s Student - gsnu200781


"KCG" wrote:

Hello friends,

I have my data in the range J14:AA14.

Please help me to create a VBA macro which will find duplicate entries in
this range and colour both cells red.

Thanx

--
KCG

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
Duplicate entries Radiorick Excel Worksheet Functions 5 March 23rd 19 11:39 AM
Macro for checking duplicate entries Ken[_2_] Excel Worksheet Functions 6 October 8th 07 12:17 PM
Getting rid of not quite duplicate entries el_grimley Excel Worksheet Functions 4 August 10th 05 02:52 PM
Duplicate entries Keggarboy New Users to Excel 3 April 30th 05 08:26 AM
Duplicate entries DMC Excel Worksheet Functions 1 December 19th 04 07:45 PM


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