use VBA to auto-filter and copy filtered data to another sheet

Eliehaddad

New Member
Joined
May 25, 2018
Messages
10
Hello,

please i need you assistance to automaticaly filter data in a specific table based on the customer name and copy the filtered data related to this customer to another worksheet using VBA

example: i need to automaticaly filter the projects by the name of the project owner and autocopy the related data of the projects to another sheet.

project namedecsriptionproject owner
marsXXXSam
venusYYYMark
earthZZZSam

<tbody>
</tbody>

so will have this result in the 2nd sheet

project namedecsriptionproject owner
marsXXXSam
earthZZZSam

<tbody>
</tbody>


thank you in advance :)
 
Ok, try this
Code:
Sub MoveDupes()
   Dim ws As Worksheet
   Dim Cl As Range
   Dim sht As Worksheet
   
   For Each sht In Sheets(Array([COLOR=#ff0000]"Joseph", "Nihale", "Lea"[/COLOR]))
      sht.Range("A5:A" & Rows.Count).EntireRow.Clear
   Next sht
   Set ws = Sheets("Report")
   If ws.AutoFilterMode Then ws.AutoFilterMode = False
   With CreateObject("scripting.dictionary")
      For Each Cl In ws.Range("C5", ws.Range("C" & Rows.Count).End(xlUp))
         If Not .exists(Cl.Value) And Cl.Value <> 0 Then
            .Add Cl.Value, Nothing
            ws.Range("A4").AutoFilter 3, Cl.Value
            ws.AutoFilter.Range.Offset(1).Copy Sheets(Split(Cl.Value)(0)).Range("A" & Rows.Count).End(xlUp).Offset(1)
         End If
      Next Cl
   End With
   ws.AutoFilterMode = False
End Sub
If you have more Project Owners add them to the array in red
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,173
Members
451,543
Latest member
cesymcox

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