+ Reply to Thread
Results 1 to 2 of 2

Copy & Paste Duplicates

Hybrid View

  1. #1
    Forum Contributor stockgoblin42's Avatar
    Join Date
    05-26-2011
    Location
    vancouver, canada
    MS-Off Ver
    Excel 2010
    Posts
    222

    Copy & Paste Duplicates

    Hi, I have a list of lines with slopes and Y-intercepts. I'd like to identify all the parralell lines (equal slopes) and copy a few bits of info from those rows to another part of the page. See the highlighted areas in the attached file.

    I take it I'll need a macro but how do I filter for duplicates first? Would I used the advanced Filter? What would the Criteria for the Criteria Range be?

    Any ideas?
    Attached Files Attached Files
    Last edited by stockgoblin42; 04-25-2013 at 04:14 PM.

  2. #2
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: Copy & Paste Duplicates

    Sub CopyPaste_Duplicates()
    Dim temp1, temp2 As String
    Dim aRow, bRow, cRow, checkRep, i As Integer
    Dim arrayC(100) As Integer
    
    
    Range("A2").Select
    aRow = ActiveCell.Row
    cRow = 2
    checkRep = 0
    i = 1
    Do
    Do
    ActiveCell.Offset(1, 0).Select
    bRow = ActiveCell.Row
    For j = 1 To 100
    If aRow = arrayC(j) Then
    Exit Do
    End If
    Next j
    
    temp1 = Round(Range("A" & aRow & "").Value, 2)
    temp2 = Round(Range("A" & bRow & "").Value, 2)
    If temp1 = temp2 Then
    If checkRep = 0 Then
    Range("A" & aRow & ":D" & aRow & "").Copy
    Range("P" & cRow & "").Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False
    cRow = cRow + 1
    checkRep = checkRep + 1
    End If
    arrayC(i) = bRow
    Range("A" & bRow & ":D" & bRow & "").Copy
    Range("P" & cRow & "").Select
        Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
            False, Transpose:=False
    i = i + 1
    cRow = cRow + 1
    Range("A" & bRow & "").Select
    End If
    Loop Until IsEmpty(ActiveCell.Offset(1, 0)) = True
    
    checkRep = 0
    Range("A" & aRow & "").Offset(1, 0).Select
    aRow = ActiveCell.Row
    Loop Until IsEmpty(ActiveCell.Offset(1, 0)) = True
    
    Range("Q:Q").Delete
    
    End Sub
    Try this.
    -If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".

    -Always upload a workbook before start your question
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    +++ If my answer(s) helped you, please add me reputation by click on * +++

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1