E
EAB1977
Hello, I am using Access 2007 to automate Excel 2007. I am trying to
accomplish a simple sort feature in one of my workbooks, but the code
appears to crash on the line .SetRange Range("A1:B" & intRow).
I am still learing the 2007 Object Model, so any info on why this does
not work would be greatly appreciated.
P.S. This workbook may be used by some users who use Excel 2003.
.Sheets("Sheet4").Select
intRow = .ActiveCell.Row - 1 'getting the last row that has
data
.ActiveWorkbook.Worksheets("Sheet4").Sort.SortFields.Clear
.ActiveWorkbook.Worksheets("Sheet4").Sort.SortFields.Add
Key:=.Range("B1:B" & intRow) _
, SortOn:=0, Order:=2, DataOption:=0
With .ActiveWorkbook.Worksheets("Sheet4").Sort
.SetRange Range("A1:B" & intRow) 'bombs here
.Header = 0
.MatchCase = False
.Orientation = 1
.SortMethod = 1
.Apply
End With
accomplish a simple sort feature in one of my workbooks, but the code
appears to crash on the line .SetRange Range("A1:B" & intRow).
I am still learing the 2007 Object Model, so any info on why this does
not work would be greatly appreciated.
P.S. This workbook may be used by some users who use Excel 2003.
.Sheets("Sheet4").Select
intRow = .ActiveCell.Row - 1 'getting the last row that has
data
.ActiveWorkbook.Worksheets("Sheet4").Sort.SortFields.Clear
.ActiveWorkbook.Worksheets("Sheet4").Sort.SortFields.Add
Key:=.Range("B1:B" & intRow) _
, SortOn:=0, Order:=2, DataOption:=0
With .ActiveWorkbook.Worksheets("Sheet4").Sort
.SetRange Range("A1:B" & intRow) 'bombs here
.Header = 0
.MatchCase = False
.Orientation = 1
.SortMethod = 1
.Apply
End With