Excel Macro Required

AstroMaz

New Member
Joined
Jan 17, 2014
Messages
8
May Peace be on everyone here !

I have a big sales sheet which has columns like date, items, amount and customer name, etc. Now what I want is following:

1. filter a specific customer,
2. copy visible data related to that customer
3. paste in a new sheet
4. name that sheet with the name of customer.

Therefore if there are 25 customers, then there will be 25 sheets with their respective customer names.

Please help me in doing that with macro, or anything !

Thanks !
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

AstroMaz

New Member
Joined
Jan 17, 2014
Messages
8
anyone please?

I found this code but I don't know how to use it,please guide me where I have to make changes?

Sub Foo()
Dim c As Range
Dim rng As Range
Dim LR As Long

LR = Cells(Rows.Count, "R").End(xlUp).Row
Set rng = Range("A1:AJ" & LR)

Range("E1:E" & LR).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range("AM1"), Unique:=True

For Each c In Range([AM2], Cells(Rows.Count, "AM").End(xlUp))
With rng
.AutoFilter
.AutoFilter Field:=5, Criteria1:=c.Value
.SpecialCells(xlCellTypeVisible).Copy
Sheets.Add(After:=Sheets(Sheets.Count)).Name = c.Value
ActiveSheet.Paste
End With
Next c

End Sub
 

Watch MrExcel Video

Forum statistics

Threads
1,126,916
Messages
5,621,602
Members
415,847
Latest member
AlpinoHirsch

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
Top