Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ew ew is offline
external usenet poster
 
Posts: 27
Default Sorting Issue

I am trying to sort three seperate arrays using the following code:

'Overhead broken down by site
'Denver
OVHsite.Range("E4").Copy
DataWks.Range("J28").PasteSpecial Paste:=xlValues
'Coastal
OVHsite.Range("O4").Copy
DataWks.Range("K28").PasteSpecial Paste:=xlValues
'Orem
OVHsite.Range("J4").Copy
DataWks.Range("L28").PasteSpecial Paste:=xlValues
'Overhead broken down by exception
'Denver
OVHsite.Range("D7:D13").Copy
DataWks.Range("N4").PasteSpecial Paste:=xlValues
'Coastal
OVHsite.Range("N7:N13").Copy
DataWks.Range("P4").PasteSpecial Paste:=xlValues
'Orem
OVHsite.Range("I7:I13").Copy
DataWks.Range("R4").PasteSpecial Paste:=xlValues
'Sort Ovh
DataWks.Range("N4:O10").sort Key1:=Range("N4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
DataWks.Range("P4:Q10").sort Key1:=Range("P4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
DataWks.Range("R4:S10").sort Key1:=Range("R4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

I am receiving the following error:

Run-time error '1004':
The sort reference is not valid. Make sure that it's within the data you
want to sort, and the first Sort By box isn't the same or blank.

What am I doing wrong? Any help would be appriciated....Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Sorting Issue

See my answer to your same question of the 13th ...
"Sorting Question" from "ewagz"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"EW"
wrote in message
I am trying to sort three seperate arrays using the following code:

'Overhead broken down by site
'Denver
OVHsite.Range("E4").Copy
DataWks.Range("J28").PasteSpecial Paste:=xlValues
'Coastal
OVHsite.Range("O4").Copy
DataWks.Range("K28").PasteSpecial Paste:=xlValues
'Orem
OVHsite.Range("J4").Copy
DataWks.Range("L28").PasteSpecial Paste:=xlValues
'Overhead broken down by exception
'Denver
OVHsite.Range("D7:D13").Copy
DataWks.Range("N4").PasteSpecial Paste:=xlValues
'Coastal
OVHsite.Range("N7:N13").Copy
DataWks.Range("P4").PasteSpecial Paste:=xlValues
'Orem
OVHsite.Range("I7:I13").Copy
DataWks.Range("R4").PasteSpecial Paste:=xlValues
'Sort Ovh
DataWks.Range("N4:O10").sort Key1:=Range("N4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
DataWks.Range("P4:Q10").sort Key1:=Range("P4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
DataWks.Range("R4:S10").sort Key1:=Range("R4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

I am receiving the following error:

Run-time error '1004':
The sort reference is not valid. Make sure that it's within the data you
want to sort, and the first Sort By box isn't the same or blank.

What am I doing wrong? Any help would be appriciated....Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
ew ew is offline
external usenet poster
 
Posts: 27
Default Sorting Issue

No good Jim. I need to know how to select the worksheet or better yet, a
better explanation to a novice coder. Thanks.

"Jim Cone" wrote:

See my answer to your same question of the 13th ...
"Sorting Question" from "ewagz"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"EW"
wrote in message
I am trying to sort three seperate arrays using the following code:

'Overhead broken down by site
'Denver
OVHsite.Range("E4").Copy
DataWks.Range("J28").PasteSpecial Paste:=xlValues
'Coastal
OVHsite.Range("O4").Copy
DataWks.Range("K28").PasteSpecial Paste:=xlValues
'Orem
OVHsite.Range("J4").Copy
DataWks.Range("L28").PasteSpecial Paste:=xlValues
'Overhead broken down by exception
'Denver
OVHsite.Range("D7:D13").Copy
DataWks.Range("N4").PasteSpecial Paste:=xlValues
'Coastal
OVHsite.Range("N7:N13").Copy
DataWks.Range("P4").PasteSpecial Paste:=xlValues
'Orem
OVHsite.Range("I7:I13").Copy
DataWks.Range("R4").PasteSpecial Paste:=xlValues
'Sort Ovh
DataWks.Range("N4:O10").sort Key1:=Range("N4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
DataWks.Range("P4:Q10").sort Key1:=Range("P4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
DataWks.Range("R4:S10").sort Key1:=Range("R4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

I am receiving the following error:

Run-time error '1004':
The sort reference is not valid. Make sure that it's within the data you
want to sort, and the first Sort By box isn't the same or blank.

What am I doing wrong? Any help would be appriciated....Thanks!


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Sorting Issue

The answer I posted on the 13th was...
"My guess is that the DataWks sheet is not the active sheet.
The Key1 ranges all refer to the active sheet."

Which means you could select the sheet before running the sort code ...
DataWks.Select

- or even better -

prefix "range" with DataWks. in three places ...

Key1:=DataWks.Range("N4"),
Key1:=DataWks.Range("P4")
Key1:=DataWks.Range("R4")

Informative reading here ...
http://www.cpearson.com/excel/newposte.htm
--
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html





"EW"
wrote in message
No good Jim.
I need to know how to select the worksheet or better yet,
a better explanation to a novice coder. Thanks.

"Jim Cone" wrote:
See my answer to your same question of the 13th ...
"Sorting Question" from "ewagz"
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"EW"
wrote in message
I am trying to sort three seperate arrays using the following code:
'Overhead broken down by site
'Denver
OVHsite.Range("E4").Copy
DataWks.Range("J28").PasteSpecial Paste:=xlValues
'Coastal
OVHsite.Range("O4").Copy
DataWks.Range("K28").PasteSpecial Paste:=xlValues
'Orem
OVHsite.Range("J4").Copy
DataWks.Range("L28").PasteSpecial Paste:=xlValues
'Overhead broken down by exception
'Denver
OVHsite.Range("D7:D13").Copy
DataWks.Range("N4").PasteSpecial Paste:=xlValues
'Coastal
OVHsite.Range("N7:N13").Copy
DataWks.Range("P4").PasteSpecial Paste:=xlValues
'Orem
OVHsite.Range("I7:I13").Copy
DataWks.Range("R4").PasteSpecial Paste:=xlValues
'Sort Ovh
DataWks.Range("N4:O10").sort Key1:=Range("N4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
DataWks.Range("P4:Q10").sort Key1:=Range("P4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
DataWks.Range("R4:S10").sort Key1:=Range("R4"), Order1:=xlAscending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

I am receiving the following error:
Run-time error '1004':
The sort reference is not valid. Make sure that it's within the data you
want to sort, and the first Sort By box isn't the same or blank.

What am I doing wrong? Any help would be appriciated....Thanks!

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 issue Dr. Schwartz[_2_] Excel Discussion (Misc queries) 2 January 29th 08 03:39 PM
Sorting issue Sige Excel Programming 13 February 10th 06 03:19 PM
Sorting Issue. Please help V-ger Excel Discussion (Misc queries) 17 November 15th 05 12:27 AM
sorting issue steve Excel Discussion (Misc queries) 4 June 22nd 05 06:28 PM
sorting issue - help gennario Excel Discussion (Misc queries) 0 February 28th 05 05:27 PM


All times are GMT +1. The time now is 09:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"