Results 1 to 6 of 6

Extracting data in groups of 3's and copying to another worksheet

Threaded View

  1. #1
    Registered User
    Join Date
    09-23-2012
    Location
    Leicester, England
    MS-Off Ver
    Excel 2010
    Posts
    6

    Extracting data in groups of 3's and copying to another worksheet

    Hi All,

    New to this forum and Excel/VBA and could really do with some help!

    I have the a table set up like the following:

    Excel Forum Pic.png

    The problem I have is that I need a Macro to extract data in sets of 3's and only if they have the same
    concatenated figure i.e. in column E.

    For the example attached then I would want Assignment 4,5,6 to be taken out (7,8 left as although these are the same concatenated number there are only two of them) then I'd want 9,10,11 and 12,13,14 (15,16 would be ignored etc).

    I'm guessing I might need a loop and an array but not a clue how to go about this?

    I have used the following code previous to extract and copy some data but it is limited by a user having to input a variable (not dynamic) and I get
    get the list to look at blocks of 3.

    Sub CopyDuplicate()
       'Copy cells of cols A,F,E,D from rows containing "Significant" in
       'col D of the active worksheet (source sheet) to cols
       'A,B,C,D of Sheet2 (destination sheet)
       Dim DestSheet        As Worksheet
       Set DestSheet = Worksheets("Sheet3")
       
       Dim sRow       As Long     'row index on source worksheet
       Dim dRow       As Long     'row index on destination worksheet
       Dim sCount     As Long
       sCount = 0
       dRow = 4
     
      For sRow = 1 To Range("D65536").End(xlDown).Row
          'use pattern matching to find "Significant" anywhere in cell
          If Cells(sRow, "E") Like "*True*" Then
             sCount = sCount + 1
             dRow = dRow + 1
             'copy cols A,F,E & D
             Cells(sRow, "B").Copy Destination:=DestSheet.Cells(dRow, "B")
             Cells(sRow, "C").Copy Destination:=DestSheet.Cells(dRow, "C")
             Cells(sRow, "D").Copy Destination:=DestSheet.Cells(dRow, "D")
             Cells(sRow, "E").Copy Destination:=DestSheet.Cells(dRow, "E")
             Cells(sRow, "F").Copy Destination:=DestSheet.Cells(dRow, "F")
          End If
       Next sRow
       
       MsgBox sCount & " Duplicate rows copied", vbInformation, "Transfer Done"
     
    End Sub
    Attached Images Attached Images
    Last edited by Cutter; 09-23-2012 at 03:49 PM. Reason: Added code tags

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