Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
When I produce "sorted" sheets using the following code below, I am not able
to carry the formatting to the new sheets. Any ideas would be appreciated. Thanks in advance! Sub ExtractReps() Dim ws1 As Worksheet Dim wsNew As Worksheet Dim rng As Range Dim cs As Integer Dim c As Range Set ws1 = Sheets("Sheet1") Set rng = Range("Database") 'extract a list of Project Officers ws1.Columns("C:C").Copy _ Destination:=Range("CM1") ws1.Columns("CM:CM").AdvancedFilter _ Action:=xlFilterCopy, _ CopyToRange:=Range("CK1"), Unique:=True cs = Cells(Rows.Count, "CK").End(xlUp).Row 'set up Criteria Area Range("CM1").Value = Range("C1").Value For Each c In Range("CK2:CK" & cs) 'add the rep name to the criteria area ws1.Range("CM2").Value = c.Value 'add new sheet (if required) 'and run advanced filter If WksExists(c.Value) Then Sheets(c.Value).Cells.Clear rng.AdvancedFilter Action:=xlFilterCopy, _ CriteriaRange:=Sheets("Sheet1").Range("CM1:CM2"), _ CopyToRange:=Sheets(c.Value).Range("A1"), _ Unique:=False Else Set wsNew = Sheets.Add wsNew.Move After:=Worksheets(Worksheets.Count) wsNew.Name = c.Value rng.AdvancedFilter Action:=xlFilterCopy, _ CriteriaRange:=Sheets("Sheet1").Range("CM1:CM2"), _ CopyToRange:=wsNew.Range("A1"), _ Unique:=False End If Next ws1.Select ws1.Columns("CK:CM").Delete End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
automatic formatting | Excel Discussion (Misc queries) | |||
automatic formatting | Excel Worksheet Functions | |||
Automatic code customizing | Excel Programming | |||
Automatic formatting help? | Excel Discussion (Misc queries) | |||
Automatic Row Formatting | Excel Discussion (Misc queries) |