Thread: Sort halted
View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Gotroots Gotroots is offline
external usenet poster
 
Posts: 114
Default Sort halted

Ryan

I stated .Activate in fact it should have been .Sort

Anyway the solution Dave Peterson provided was successful.

Thank you Ryan, I appreciate your effort.



"Gotroots" wrote:


Sorry to report but it has stopped at:
.Activate


"Ryan H" wrote:

Try using this:

Workbooks.Open Filename:="Z:\Excel docs\Uses\Uses_A.xlsm"

With ActiveWorkbook.Sheets("A")
.Activate
.Range("B11:Z7800").Select
.Sort.SortFields.Clear
.Sort.SortFields.Add Key:=Range("B11:B7800"), _
SortOn:=xlSortOnValues, _
Order:=xlAscending, _
DataOption:=xlSortNormal
.Sort
.SetRange Range("B11:Z7800")
End With

Hope this helps! If so, let me know, click "YES" below.
--
Cheers,
Ryan


"Gotroots" wrote:

Run-time error '1004':
Select method of Range class failed

Would it be anything to do with the fact the workbook is slow to open and
the code proceeds prematurely to the next line in the code.

The workbook is not particularly large 1.17MB although there are upwards of
100,000 array formulas contained in the workbook.

"Ryan H" wrote:

I'm able to select it just fine. The code works for me. What is description
of the error you are getting?
--
Cheers,
Ryan


"Gotroots" wrote:

I am puzzled why the following code stops when it reaches
Range("B11:Z7800").Select

Workbooks.Open Filename:="Z:\Excel docs\Uses\Uses_A.xlsm"
Sheets("A").Select
Range("B11:Z7800").Select
ActiveWorkbook.Worksheets("A").Sort.SortFields.Cle ar
ActiveWorkbook.Worksheets("A").Sort.SortFields.Add
Key:=Range("B11:B7800" _
), SortOn:=xlSortOnValues, Order:=xlAscending,
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("A").Sort
.SetRange Range("B11:Z7800")

Anyone see something not quite right with the code.

Thank you for your time.