View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Harald Staff Harald Staff is offline
external usenet poster
 
Posts: 292
Default Cells.Select won't work!!!

Hei Neil

You don't have to activate or select anything to sort a table. If you
explain what this
CSV = ActiveCell.Value
Windows(CSV).Activate
does, I could perhaps write you a working demo.

HTH. best wishes Harald


"Neil Cash" skrev i melding
...
I have a workbook that contains a macro that opens a file. Then the file

is
sorted the way it should. But I get an error on the Cells.Select command:
Run-time error '1004': Select method of Range class failed
Here's what my code looks like:

ActiveWorkbook.Save
Range("D4").Select
CSV = ActiveCell.Value
Windows(CSV).Activate
Cells.Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Key2:=Range("A2") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2 _
:=xlSortNormal

Is there a different way to select all the cells in the workbook? Does
anyone have any ideas about what I'm missing? Thanks in advance. I don't
know if it matters, but the file that is being sorted is a csv file.