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
Bookmarks