Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 19th, 2014, 04:48 AM
Registered User
 
Join Date: Feb 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default find and move the duplicate values in another sheet

Hello, please help me with a code macro, is to move the duplicate values in sheet2,

I want to change that results from sheet 2 to be placed on columns A and B,
not as it is now spread all over the sheet 2
Code:
Sub ertert() 
    Dim x, y(), i&, j&, t(), bu As Boolean 
    x = Sheets("Foaie1").Range("A2").CurrentRegion.Value 
    Redim y(1 To UBound(x), 1 To UBound(x, 2)) 
    With CreateObject("Scripting.Dictionary") 
        .CompareMode = 1 
        For i = 1 To UBound(x) 
            For j = 1 To UBound(x, 2) 
                If Len(x(i, j)) Then 
                    If .Exists(x(i, j)) Then 
                        t = .Item(x(i, j)): bu = True 
                        y(t(0), t(1)) = x(i, j): y(i, j) = x(i, j) 
                        x(i, j) = "": x(t(0), t(1)) = "" 
                    Else 
                        .Item(x(i, j)) = Array(i, j) 
                    End If 
                End If 
            Next j 
        Next i 
    End With 
    Sheets("Foaie1").Range("A2").Resize(i - 1, j - 1).Value = x 
    If bu Then Sheets("Foaie2").Range("A2").Resize(i - 1, j - 1).Value = y() 
End Sub
Thank you





Similar Threads
Thread Thread Starter Forum Replies Last Post
Open Workbook,Copy Sheet,Move Sheet, Close/Save ptrussell2009 Excel VBA 0 June 13th, 2008 02:28 PM
How to remove duplicate row from sheet ketannsharma Excel VBA 1 February 18th, 2007 03:32 AM
loop values and text box values move mateenmohd Classic ASP Basics 2 April 5th, 2005 11:33 PM
find duplicate name on a table vickr1z Access 4 March 23rd, 2005 06:02 AM
sql command to find duplicate records? qwjunk Classic ASP Databases 1 January 31st, 2004 03:32 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.