Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 86
Default 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
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
Sorting problem Ting Li[_2_] Excel Worksheet Functions 5 February 5th 09 01:59 PM
sorting problem sweetpea Excel Worksheet Functions 3 February 25th 07 07:23 PM
Not Sorting Problem? lawdoggy Excel Worksheet Functions 0 August 25th 05 07:49 PM
Sorting problem elayem[_3_] Excel Programming 0 October 15th 04 07:51 PM


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