Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default Filter a sheet by value in column P

Morning All
I need to sort an excel sheet with 20000 rows of data into separate
worksheets according to the customer name in column P. I can do this manually
but am looking for an easy quick fix due to time. I have approx 180 different
customers.

Thankks in Advance

Ajay
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Filter a sheet by value in column P

the code below assumes the original worksheet is called Summary and there is
one header row on the sheet. The code will sort the Summary sheet by column
P and then copy each customers data to a new worksheet. The new worksheet
will be named using the customer name. Make sure no sheets already exist
with the customer name.


Sub splitcustomers()

Set SumSht = Sheets("Summary")
With SumSht
Lastrow = .Range("P" & Rows.Count).End(xlUp).Row
Set SortRange = .Rows("2:" & Lastrow)
SortRange.Sort _
key1:=.Range("P2"), _
order1:=xlAscending, _
header:=xlNo

RowCount = 2
StartRow = RowCount
Do While .Range("P" & RowCount) < ""
'check to see where one customer ends
If .Range("P" & RowCount) < .Range("P" & (RowCount + 1)) Then
'Create New worksheet at end of workbook
Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
'rename new worksheet
customer = .Range("P" & RowCount)
newsht.Name = customer

'Copy head row to new sheet
.Rows(1).Copy Destination:=newsht.Rows(1)
'Copy customers to new sheet
Set CopyRange = .Rows(StartRow & ":" & RowCount)
CopyRange.Copy Destination:=newsht.Rows(2)
StartRow = RowCount + 1
End If
RowCount = RowCount + 1

Loop
End With


End Sub


"Ajay" wrote:

Morning All
I need to sort an excel sheet with 20000 rows of data into separate
worksheets according to the customer name in column P. I can do this manually
but am looking for an easy quick fix due to time. I have approx 180 different
customers.

Thankks in Advance

Ajay

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 43
Default Filter a sheet by value in column P

Just the job Many thanks Joel

"Joel" wrote:

the code below assumes the original worksheet is called Summary and there is
one header row on the sheet. The code will sort the Summary sheet by column
P and then copy each customers data to a new worksheet. The new worksheet
will be named using the customer name. Make sure no sheets already exist
with the customer name.


Sub splitcustomers()

Set SumSht = Sheets("Summary")
With SumSht
Lastrow = .Range("P" & Rows.Count).End(xlUp).Row
Set SortRange = .Rows("2:" & Lastrow)
SortRange.Sort _
key1:=.Range("P2"), _
order1:=xlAscending, _
header:=xlNo

RowCount = 2
StartRow = RowCount
Do While .Range("P" & RowCount) < ""
'check to see where one customer ends
If .Range("P" & RowCount) < .Range("P" & (RowCount + 1)) Then
'Create New worksheet at end of workbook
Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
'rename new worksheet
customer = .Range("P" & RowCount)
newsht.Name = customer

'Copy head row to new sheet
.Rows(1).Copy Destination:=newsht.Rows(1)
'Copy customers to new sheet
Set CopyRange = .Rows(StartRow & ":" & RowCount)
CopyRange.Copy Destination:=newsht.Rows(2)
StartRow = RowCount + 1
End If
RowCount = RowCount + 1

Loop
End With


End Sub


"Ajay" wrote:

Morning All
I need to sort an excel sheet with 20000 rows of data into separate
worksheets according to the customer name in column P. I can do this manually
but am looking for an easy quick fix due to time. I have approx 180 different
customers.

Thankks in Advance

Ajay

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 189
Default Filter a sheet by value in column P

Hi,

Try this
http://www.rondebruin.nl/copy5.htm
--
_______________________
Click "Yes" if it helps
________
Thanks
Suleman Peerzade


"Ajay" wrote:

Morning All
I need to sort an excel sheet with 20000 rows of data into separate
worksheets according to the customer name in column P. I can do this manually
but am looking for an easy quick fix due to time. I have approx 180 different
customers.

Thankks in Advance

Ajay

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
How do I count nonblanks in column A when I filter by column B RP3 Excel Worksheet Functions 5 January 13th 09 05:05 PM
filter a column from other sheet. nader Excel Discussion (Misc queries) 4 July 9th 08 09:43 AM
Copy/filter data in a sheet from another sheet Sheikh Saadi Excel Discussion (Misc queries) 1 November 22nd 07 08:28 AM
Filter Range on Sheet B Based on List on Sheet A Brent E Excel Discussion (Misc queries) 4 April 23rd 07 04:10 PM
'Copy to' Advance Filter depend only on sheet ID not start sheet Sandy Yates Excel Worksheet Functions 0 April 4th 06 03:48 AM


All times are GMT +1. The time now is 02:23 PM.

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"