Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting Problem
I have name & address data that I want to format. I can't seem to get this
to work. It stops on the .Header statement with an Error 438 What am I missing, now, please? Jim Berglund Option Explicit Sub SortAndColor() Dim q, i As Long With ActiveSheet Columns("A:G").Select Selection.Columns.AutoFit q = .Range("A" & Rows.Count).End(xlUp).Row .Sort.SortFields.Clear .Sort.SortFields.Add Key:=Range("F1:F" & q), SortOn:=xlSortOnValues, Order:=xlDescending, _ DataOption:=xlSortNormal .Sort.SortFields.Add Key:=Range("C1:C" & q), SortOn:=xlSortOnValues, Order:=xlDescending, _ DataOption:=xlSortNormal .Sort.SetRange Range("A1:F" & q) .Header = xlNo .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply For i = 1 To q Step 2 .Range(Cells(i, 1), Cells(i, 5)).Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorDark1 .TintAndShade = -4.99893185216834E-02 .PatternTintAndShade = 0 Next .Range("A1:G1").Insert Shift:=xlDown .Range("A1").FormulaR1C1 = "LAST NAME" .Range("B1").FormulaR1C1 = "FIRST NAME" .Range("C1").FormulaR1C1 = "ADDRESS" .Range("D1").FormulaR1C1 = "CITY" .Range("E1").FormulaR1C1 = "PROV" .Range("F1").FormulaR1C1 = "POSTAL CODE" .Range("G1").FormulaR1C1 = "HOME PHONE" .Rows("1:1").Select .Selection.Font.Bold = True .PageSetup.PrintArea = "$A:$G" End With End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting Problem
Hi
Only a quick look but your With syntax has Activesheet. Header = xlNo effectively. I would guess your Header parent should be a range? regards Paul On Jun 3, 9:19*pm, "Jim Berglund" wrote: I have name & address data that I want to format. I can't seem to get this to work. It stops on the .Header statement with an Error 438 What am I missing, now, please? Jim Berglund Option Explicit Sub SortAndColor() Dim q, i As Long * * With ActiveSheet * * Columns("A:G").Select * * Selection.Columns.AutoFit * * * * * * q = .Range("A" & Rows.Count).End(xlUp).Row * * .Sort.SortFields.Clear * * .Sort.SortFields.Add Key:=Range("F1:F" & q), SortOn:=xlSortOnValues, Order:=xlDescending, _ * * * * * * * * * * * * DataOption:=xlSortNormal * * .Sort.SortFields.Add Key:=Range("C1:C" & q), SortOn:=xlSortOnValues, Order:=xlDescending, _ * * * * * * * * * * * * DataOption:=xlSortNormal * * .Sort.SetRange Range("A1:F" & q) * * * * .Header = xlNo * * * * .MatchCase = False * * * * .Orientation = xlTopToBottom * * * * .SortMethod = xlPinYin * * * * .Apply * * For i = 1 To q Step 2 * * * * .Range(Cells(i, 1), Cells(i, 5)).Interior * * * * * * .Pattern = xlSolid * * * * * * .PatternColorIndex = xlAutomatic * * * * * * .ThemeColor = xlThemeColorDark1 * * * * * * .TintAndShade = -4.99893185216834E-02 * * * * * * .PatternTintAndShade = 0 * * Next * * .Range("A1:G1").Insert Shift:=xlDown * * .Range("A1").FormulaR1C1 = "LAST NAME" * * .Range("B1").FormulaR1C1 = "FIRST NAME" * * .Range("C1").FormulaR1C1 = "ADDRESS" * * .Range("D1").FormulaR1C1 = "CITY" * * .Range("E1").FormulaR1C1 = "PROV" * * .Range("F1").FormulaR1C1 = "POSTAL CODE" * * .Range("G1").FormulaR1C1 = "HOME PHONE" * * .Rows("1:1").Select * * .Selection.Font.Bold = True * * .PageSetup.PrintArea = "$A:$G" * * End With End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sorting Problem
Thanks Paul. I have it working, now.
Jim "Paul Robinson" wrote in message ... Hi Only a quick look but your With syntax has Activesheet. Header = xlNo effectively. I would guess your Header parent should be a range? regards Paul On Jun 3, 9:19 pm, "Jim Berglund" wrote: I have name & address data that I want to format. I can't seem to get this to work. It stops on the .Header statement with an Error 438 What am I missing, now, please? Jim Berglund Option Explicit Sub SortAndColor() Dim q, i As Long With ActiveSheet Columns("A:G").Select Selection.Columns.AutoFit q = .Range("A" & Rows.Count).End(xlUp).Row .Sort.SortFields.Clear .Sort.SortFields.Add Key:=Range("F1:F" & q), SortOn:=xlSortOnValues, Order:=xlDescending, _ DataOption:=xlSortNormal .Sort.SortFields.Add Key:=Range("C1:C" & q), SortOn:=xlSortOnValues, Order:=xlDescending, _ DataOption:=xlSortNormal .Sort.SetRange Range("A1:F" & q) .Header = xlNo .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply For i = 1 To q Step 2 .Range(Cells(i, 1), Cells(i, 5)).Interior .Pattern = xlSolid .PatternColorIndex = xlAutomatic .ThemeColor = xlThemeColorDark1 .TintAndShade = -4.99893185216834E-02 .PatternTintAndShade = 0 Next .Range("A1:G1").Insert Shift:=xlDown .Range("A1").FormulaR1C1 = "LAST NAME" .Range("B1").FormulaR1C1 = "FIRST NAME" .Range("C1").FormulaR1C1 = "ADDRESS" .Range("D1").FormulaR1C1 = "CITY" .Range("E1").FormulaR1C1 = "PROV" .Range("F1").FormulaR1C1 = "POSTAL CODE" .Range("G1").FormulaR1C1 = "HOME PHONE" .Rows("1:1").Select .Selection.Font.Bold = True .PageSetup.PrintArea = "$A:$G" End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Sorting problem | Excel Worksheet Functions | |||
sorting problem | Excel Worksheet Functions | |||
Not Sorting Problem? | Excel Worksheet Functions | |||
Sorting problem | Excel Programming |