Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 217
Default Splitting data into seperate worksheets with data change


This is a long shot... But can anyone help me with a macro?

I have a set of data like the example below:

Name City Number

J Bloggs London 5
I Grass London 6
F Perry Manchester 2
L Owen Bournemouth 3
V Steele Liverpool 1

I need a macro to take the data and split it according to the City Name and
put each section in a new workbook. So I need a workbook for London,
Manchester, Bournemouth & Liverpool in this instance with the relevant data
pasted into it from the main sheet.

Is this possible and how would I go about creating this please?

I thank anyone for their help!!!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Splitting data into seperate worksheets with data change


Hi Louise

See this page
http://www.rondebruin.nl/copy5.htm

Try the workbook example


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Louise" wrote in message ...
This is a long shot... But can anyone help me with a macro?

I have a set of data like the example below:

Name City Number

J Bloggs London 5
I Grass London 6
F Perry Manchester 2
L Owen Bournemouth 3
V Steele Liverpool 1

I need a macro to take the data and split it according to the City Name and
put each section in a new workbook. So I need a workbook for London,
Manchester, Bournemouth & Liverpool in this instance with the relevant data
pasted into it from the main sheet.

Is this possible and how would I go about creating this please?

I thank anyone for their help!!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 217
Default Splitting data into seperate worksheets with data change


Thanks for the response Don but I what I failed to mention in my post is that
I have to create 6-10 workbooks from one file of 65000 rows, and I need to do
this with 8 original files, so to do it manually will take FOREVER - so I'd
rather automate it...


"Don Guillett" wrote:

Can you just use datafilterautofilter and filter on the city.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Louise" wrote in message
...
This is a long shot... But can anyone help me with a macro?

I have a set of data like the example below:

Name City Number

J Bloggs London 5
I Grass London 6
F Perry Manchester 2
L Owen Bournemouth 3
V Steele Liverpool 1

I need a macro to take the data and split it according to the City Name
and
put each section in a new workbook. So I need a workbook for London,
Manchester, Bournemouth & Liverpool in this instance with the relevant
data
pasted into it from the main sheet.

Is this possible and how would I go about creating this please?

I thank anyone for their help!!!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 217
Default Splitting data into seperate worksheets with data change


This looks perfect - Thank you! :)

"Ron de Bruin" wrote:

Hi Louise

See this page
http://www.rondebruin.nl/copy5.htm

Try the workbook example


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Louise" wrote in message ...
This is a long shot... But can anyone help me with a macro?

I have a set of data like the example below:

Name City Number

J Bloggs London 5
I Grass London 6
F Perry Manchester 2
L Owen Bournemouth 3
V Steele Liverpool 1

I need a macro to take the data and split it according to the City Name and
put each section in a new workbook. So I need a workbook for London,
Manchester, Bournemouth & Liverpool in this instance with the relevant data
pasted into it from the main sheet.

Is this possible and how would I go about creating this please?

I thank anyone for their help!!!




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Splitting data into seperate worksheets with data change


Lousie,
this may do what you want:

Sub FilterDataToWorkBook()
Dim ws1 As Worksheet
Dim wsNew As Workbook
Dim rng As Range
Dim lr As Integer
Dim c As Range

'worksheet where your data is stored
'change sheet name as required
Set ws1 = ThisWorkbook.Worksheets("Sheet1")

With ws1

lr = .Cells(.Rows.Count, "A").End(xlUp).Row


Set rng = .Range("A1:C" & lr)

'extract list
.Columns("B:B").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=.Range("J1"), Unique:=True

lr = .Cells(.Rows.Count, "J").End(xlUp).Row

'set up Criteria Area
.Range("L1").Value = .Range("B1").Value

For Each c In .Range("J2:J" & lr)
'add the name to the criteria area
.Range("L2").Value = c.Value


'add new workbook and run advanced filter
Set wsNew = Workbooks.Add
wsNew.Sheets(1).Name = c.Value
rng.AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=.Range("L1:L2"), _
CopyToRange:=wsNew.Sheets(1).Range("A1"), _
Unique:=False

Next

.Activate
.Columns("J:L").Delete

End With
End Sub

--
jb


"Louise" wrote:

This is a long shot... But can anyone help me with a macro?

I have a set of data like the example below:

Name City Number

J Bloggs London 5
I Grass London 6
F Perry Manchester 2
L Owen Bournemouth 3
V Steele Liverpool 1

I need a macro to take the data and split it according to the City Name and
put each section in a new workbook. So I need a workbook for London,
Manchester, Bournemouth & Liverpool in this instance with the relevant data
pasted into it from the main sheet.

Is this possible and how would I go about creating this please?

I thank anyone for their help!!!

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 217
Default Splitting data into seperate worksheets with data change

Hi

I finally got around to using this for real and it works great, only thing
is the macro is not completing and is erroring out. I go to debug and it
shows me it has broken at this point (I have included a little above it too
but it the yellow highlights My_Range.AutoFilter....):

'loop through the unique list in ws2 and filter/copy to a new sheet
Lrow = .Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In .Range("A4:A" & Lrow)
'Filter the range
My_Range.AutoFilter Field:=FieldNum, Criteria1:="=" & _
Replace(Replace(Replace(cell.Value, "~", "~~"), "*", "~*"),
"?", "~?")

I have used the code you have labelled as Create a new workbook for all
unique values which is precisely what I need to do.

My workbook is named Test Data, my worksheet is named Sheet1. I have
columns A - Q and am using column H as my data change column. There are
approx 2000 records in my spreadsheet. I think I must have not changed
something but have no idea with such complicated code what to change.

I checked and when it needs debugging, a new folder has been created and all
workbooks that I am expecting to have been created are present and full of
correct info. My Test Data workbook has only Column A remaining with the
data change criteria headings and shortcut links to the new workbooks.

Can someone tell me why this is erroring and how I can get the macro to
complete in an orderly fashion?

Many Thanks!!! :)



"Ron de Bruin" wrote:

Hi Louise

See this page
http://www.rondebruin.nl/copy5.htm

Try the workbook example


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Louise" wrote in message ...
This is a long shot... But can anyone help me with a macro?

I have a set of data like the example below:

Name City Number

J Bloggs London 5
I Grass London 6
F Perry Manchester 2
L Owen Bournemouth 3
V Steele Liverpool 1

I need a macro to take the data and split it according to the City Name and
put each section in a new workbook. So I need a workbook for London,
Manchester, Bournemouth & Liverpool in this instance with the relevant data
pasted into it from the main sheet.

Is this possible and how would I go about creating this please?

I thank anyone for their help!!!


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Splitting data into seperate worksheets with data change

Hi Louise

I like to see your test workbook

Send it to me private and I take a look



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Louise" wrote in message ...
Hi

I finally got around to using this for real and it works great, only thing
is the macro is not completing and is erroring out. I go to debug and it
shows me it has broken at this point (I have included a little above it too
but it the yellow highlights My_Range.AutoFilter....):

'loop through the unique list in ws2 and filter/copy to a new sheet
Lrow = .Cells(Rows.Count, "A").End(xlUp).Row
For Each cell In .Range("A4:A" & Lrow)
'Filter the range
My_Range.AutoFilter Field:=FieldNum, Criteria1:="=" & _
Replace(Replace(Replace(cell.Value, "~", "~~"), "*", "~*"),
"?", "~?")

I have used the code you have labelled as Create a new workbook for all
unique values which is precisely what I need to do.

My workbook is named Test Data, my worksheet is named Sheet1. I have
columns A - Q and am using column H as my data change column. There are
approx 2000 records in my spreadsheet. I think I must have not changed
something but have no idea with such complicated code what to change.

I checked and when it needs debugging, a new folder has been created and all
workbooks that I am expecting to have been created are present and full of
correct info. My Test Data workbook has only Column A remaining with the
data change criteria headings and shortcut links to the new workbooks.

Can someone tell me why this is erroring and how I can get the macro to
complete in an orderly fashion?

Many Thanks!!! :)



"Ron de Bruin" wrote:

Hi Louise

See this page
http://www.rondebruin.nl/copy5.htm

Try the workbook example


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm




"Louise" wrote in message ...
This is a long shot... But can anyone help me with a macro?

I have a set of data like the example below:

Name City Number

J Bloggs London 5
I Grass London 6
F Perry Manchester 2
L Owen Bournemouth 3
V Steele Liverpool 1

I need a macro to take the data and split it according to the City Name and
put each section in a new workbook. So I need a workbook for London,
Manchester, Bournemouth & Liverpool in this instance with the relevant data
pasted into it from the main sheet.

Is this possible and how would I go about creating this please?

I thank anyone for their help!!!


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
SPLITTING DATA INTO NEW WORKSHEETS FROM ONE WORKSHEET Romeo Excel Discussion (Misc queries) 3 November 21st 08 05:01 PM
Splitting data from sheets into seperate workbooks based on formul bUncE Excel Worksheet Functions 1 September 7th 07 05:55 PM
splitting data across worksheets newshoes Excel Discussion (Misc queries) 3 November 13th 06 05:19 PM
How do I seperate data from a pivot into seperate worksheets? Shannon Excel Discussion (Misc queries) 5 August 25th 05 06:07 AM
matching data on seperate worksheets Dale[_9_] Excel Programming 2 January 24th 04 10:33 PM


All times are GMT +1. The time now is 04:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"