create duplicate files based on cell value

sur

Board Regular
Joined
Jul 4, 2011
Messages
177
Hello team
i have workbook, with regions values raw data and pivots,
i need to create a separate files based on the regions.

NOTe; should not close the main workbook.
Please help
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
In which column are the regions located. How many regions? Names of regions?

Which columns to be copied?

New file or new worksheets as part of the existing file?

Not enough information provided. Help us to help you by providing full details of what is to happen. There is no generic answer for your situation.
 
Upvote 0
In Column "A", in a existing sheet.

however, i am trying to split into sheets with a below code, getting a bug with. Please help

Sub splitdata_to_Sheets()
Dim wsAll As Worksheet
Dim wsCrit As Worksheet
Dim wsNew As Worksheet
Dim LastRow As Long
Dim LastRowCrit As Long
Dim I As Long


ActiveSheet.Name = "Master sheet"

Set wsAll = Worksheets("Master sheet") ' change All to the name of the worksheet the existing data is on

LastRow = wsAll.Range("L" & Rows.Count).End(xlUp).Row

Set wsCrit = Worksheets.Add

' column A has the criteria
wsAll.Range("A1:N" & LastRow).AdvancedFilter Action:=xlFilterCopy, CopyToRange:=wsCrit.Range("A1"), Unique:=True

LastRowCrit = wsCrit.Range("L" & Rows.Count).End(xlUp).Row
For I = 2 To LastRowCrit

Set wsNew = Worksheets.Add
wsNew.Name = wsCrit.Range("L2")
wsAll.Rows("1:" & LastRow).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=wsCrit.Range("L1:L2"), _
CopyToRange:=wsNew.Range("A1"), Unique:=False
wsCrit.Rows(2).Delete

Next I



End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,871
Members
452,363
Latest member
merico17

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