Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-17-2016, 10:40 PM
roderh roderh is offline in each row mark duplicates Windows 7 64bit in each row mark duplicates Office 2010 32bit
Novice
in each row mark duplicates
 
Join Date: May 2014
Posts: 17
roderh is on a distinguished road
Default in each row mark duplicates

Hi,



could someone please help me with this problem?

I would like to have a makro, that marks duplicates in each row in red. The solution should look like seen in the screenshot or in xlsm.

Thank you in advance!
Attached Images
File Type: jpg duplicates in red.jpg (19.7 KB, 21 views)
Attached Files
File Type: xlsm duplicates in red.xlsm (8.9 KB, 13 views)
Reply With Quote
  #2  
Old 06-17-2016, 11:23 PM
macropod's Avatar
macropod macropod is offline in each row mark duplicates Windows 7 64bit in each row mark duplicates Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You don't need a macro for this - you can do it with a conditional format using the formula:
=COUNTIF($A$1:A1,A1)>1
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 06-17-2016, 11:29 PM
roderh roderh is offline in each row mark duplicates Windows 7 64bit in each row mark duplicates Office 2010 32bit
Novice
in each row mark duplicates
 
Join Date: May 2014
Posts: 17
roderh is on a distinguished road
Default

Thank you very much for your reply!

I was not clear about the specification (sorry!):
1) There are more than one row
2) it has to be a macro
Reply With Quote
  #4  
Old 06-17-2016, 11:38 PM
macropod's Avatar
macropod macropod is offline in each row mark duplicates Windows 7 64bit in each row mark duplicates Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You can do it with conditional formatting for however many rows of data you have> A macro isn't needed, so why are you insistent on one?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 06-17-2016, 11:43 PM
roderh roderh is offline in each row mark duplicates Windows 7 64bit in each row mark duplicates Office 2010 32bit
Novice
in each row mark duplicates
 
Join Date: May 2014
Posts: 17
roderh is on a distinguished road
Default

Because in fact it is a very large table and it seems conditional formating cripples performance (furthermore it needs only to run once)
Reply With Quote
  #6  
Old 06-18-2016, 12:07 AM
macropod's Avatar
macropod macropod is offline in each row mark duplicates Windows 7 64bit in each row mark duplicates Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim lRow As Long, lCol As Long, r As Long, c As Long
With ActiveSheet
  .UsedRange
  With .Cells.SpecialCells(xlCellTypeLastCell)
    lRow = .Row
    lCol = .Column
  End With
  For r = 1 To lRow
    For c = 2 To lCol
      If Application.WorksheetFunction.CountIf(.Range(.Cells(r, 1), .Cells(r, c)), .Cells(r, c).Value) > 1 Then
        .Cells(r, c).Font.ColorIndex = 3
      End If
    Next
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 06-18-2016, 12:15 AM
roderh roderh is offline in each row mark duplicates Windows 7 64bit in each row mark duplicates Office 2010 32bit
Novice
in each row mark duplicates
 
Join Date: May 2014
Posts: 17
roderh is on a distinguished road
Default

Great! Thank you! This helps me a lot!
(only thing is: makro does not make a distinction between "smith" and "Smith", but I can live with that)
Reply With Quote
  #8  
Old 06-18-2016, 01:23 PM
KunleExcel KunleExcel is offline in each row mark duplicates Windows 8 in each row mark duplicates Office 2010 32bit
Novice
 
Join Date: Jun 2016
Location: Nigeria
Posts: 17
KunleExcel is on a distinguished road
Default Mark Duplicates

This one makes distinction between smith and Smith
Sub MarkDups()
Dim SRange As Range
Set SRange = Range("A1", Range("A1").End(xlToRight))

Dim c As Range
For Each c In SRange
Set c = SRange.Find(c, , , xlWhole, , , True)
If Not c Is Nothing Then
Dim firstAddress As String
firstAddress = c.Address
Do
Set c = SRange.FindNext(c)
If c.Address <> firstAddress Then
c.Font.Color = vbRed
End If
Loop While Not c Is Nothing And c.Address <> firstAddress

End If
Next c
End Sub
Reply With Quote
  #9  
Old 06-18-2016, 08:34 PM
macropod's Avatar
macropod macropod is offline in each row mark duplicates Windows 7 64bit in each row mark duplicates Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

KunleExcel: Your code colours not only the duplicate but also the original. Also, it processes only the first row, not all rows. Finally, when posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 09-29-2016, 09:01 PM
kalak kalak is offline in each row mark duplicates Windows 10 in each row mark duplicates Office 2013
Novice
 
Join Date: Sep 2016
Posts: 1
kalak is on a distinguished road
Default

Code:
Sub dcmdc()
Dim d As Object, r, s
Set d = CreateObject("scripting.dictionary")
d.comparemode = 0
For Each r In ActiveSheet.UsedRange.Rows
    For Each s In r.Cells
        If Len(s) > 0 Then _
            If d(s.Value) = 1 Then s.Font.Color = vbRed  Else d(s.Value) = 1
    Next s
    d.RemoveAll
Next r
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sequencing duplicates balajigade Excel Programming 3 10-04-2015 03:31 PM
in each row mark duplicates VBA: Delete duplicates in each row bandaanders Excel Programming 2 09-02-2015 08:15 AM
in each row mark duplicates Removing duplicates saurabhlotankar Excel Programming 14 05-26-2015 10:13 AM
Mail duplicates mixy Outlook 0 02-10-2011 12:54 AM
in each row mark duplicates sum of duplicates zxmax Excel 1 09-29-2006 08:29 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft