VBA: Advanced Filter and copy data

Janb

New Member
Joined
Feb 19, 2009
Messages
39
Below is a part of my code. The problem is that the first copied data is overwritten bij the next set of data.

Which code do I need to paste the second set of data below the first set. And the third set below the second one.

E.G. My first set of data is copied in range A2:A5. Then I want the next set of data copied in the range A6:A10.

VBA Code:
        Set rngFilterCriteria = shtFilterCriteria.Range("E3:G4")
        Set rngCopyToRange = shtArchiefMutaties.Range("A1:H1")
        
        'Het bereik van de unieke lijst op het werkblad FilterCriteria
        arrUniekeClient = shtFilterCriteria.Range("I4:I" & lngLastRowUniekeClient).Value
        
        'In deze loop gebeurt het volgende:
        
        'Het gehele bereik wordt meegenomen in de For i
        For i = LBound(arrUniekeClient, 1) To UBound(arrUniekeClient, 1)
            'De waarde van de unieke lijst wordt weggeschreven in cel G4
            shtFilterCriteria.Range("G4").Value = arrUniekeClient(i, 1)
            'De mutaties worden gearchiveerd.
            
            'Het wegschrijven vindt plaats.
            
            shtMutaties.Range("A6").CurrentRegion.AdvancedFilter Action:=xlFilterCopy, _
                                                                CriteriaRange:=rngFilterCriteria, _
                                                                CopyToRange:=rngCopyToRange
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Filter in place rather than FilterCopy then use the classic Range.Copy method …​
 
Upvote 0
Solution

Forum statistics

Threads
1,214,990
Messages
6,122,626
Members
449,093
Latest member
catterz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top