Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Pasting to new worksheet with formats

I have a master report of customer sales. In column 10 is the sales
region. I am trying to create individual sheets by region. I have been
using Filtering to only get the data.
1)Is there a better way? and

2) Is there a way to copy the data and the formats,including column
widths. Every time I try to Paste Special Paste:xlColumnWidth I get errors.


Sub Regions()

Set lastcell = Cells.SpecialCells(xlLastCell)
ActiveSheet.Name = "ALL"
Worksheets.Add.Move after:=Worksheets(Worksheets.count)
ActiveSheet.Name = "EAST"
Worksheets.Add.Move after:=Worksheets(Worksheets.count)
ActiveSheet.Name = "CENTRAL"
Worksheets.Add.Move after:=Worksheets(Worksheets.count)
ActiveSheet.Name = "WEST"
Worksheets("ALL").Activate



Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="EAST"
Range("A1", lastcell).Select
Selection.Copy Worksheets("EAST").Range("A1")


Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="CENTRAL"
Range("A1", lastcell).Select
Selection.Copy Worksheets("CENTRAL").Range("A1")

Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="WEST"
Range("A1", lastcell).Select
Selection.Copy Worksheets("WEST").Range("A1")


End Sub


Scott

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Pasting to new worksheet with formats

Not sure why you would think applying a filter is a bad way. If you have
working code, what is the struggle?

If you are using xl 2000, the variable for columnwidth wasn't defined. You
need to use 8 as the argument as I recall.

in xl97, this option was not available (added in xl2000)

--
Regards,
Tom Ogilvy


scott wrote in message
...
I have a master report of customer sales. In column 10 is the sales
region. I am trying to create individual sheets by region. I have been
using Filtering to only get the data.
1)Is there a better way? and

2) Is there a way to copy the data and the formats,including column
widths. Every time I try to Paste Special Paste:xlColumnWidth I get

errors.


Sub Regions()

Set lastcell = Cells.SpecialCells(xlLastCell)
ActiveSheet.Name = "ALL"
Worksheets.Add.Move after:=Worksheets(Worksheets.count)
ActiveSheet.Name = "EAST"
Worksheets.Add.Move after:=Worksheets(Worksheets.count)
ActiveSheet.Name = "CENTRAL"
Worksheets.Add.Move after:=Worksheets(Worksheets.count)
ActiveSheet.Name = "WEST"
Worksheets("ALL").Activate



Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="EAST"
Range("A1", lastcell).Select
Selection.Copy Worksheets("EAST").Range("A1")


Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="CENTRAL"
Range("A1", lastcell).Select
Selection.Copy Worksheets("CENTRAL").Range("A1")

Range("A1").Select
Selection.AutoFilter
Selection.AutoFilter Field:=10, Criteria1:="WEST"
Range("A1", lastcell).Select
Selection.Copy Worksheets("WEST").Range("A1")


End Sub


Scott



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
Pasting formats and values without formulas Rae Excel Worksheet Functions 3 June 20th 09 04:48 PM
RESTRICT PASTING FORMATS FARAZ QURESHI Excel Discussion (Misc queries) 1 March 26th 08 12:26 PM
holding worksheet formats when copying/pasting hsyrddy Excel Discussion (Misc queries) 2 November 28th 07 09:59 PM
pasting links and formats prakash Excel Discussion (Misc queries) 2 August 28th 06 12:00 PM
Formats when cutting and pasting Kayle Z Excel Discussion (Misc queries) 1 February 9th 06 03:57 AM


All times are GMT +1. The time now is 10:00 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"