Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Need help Selecting, Sorting, Autofitting a range

Set rng = NwSht.Range("A1:G8", NwSht.Range("G65536").End(xlUp)).Select
rng.Sort Key1:=Range("A2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
rng.Columns.AutoFit
NwSht.Range("A1").Select
NwSht.Activate

Not working, what am I doing wrong?

says object required on the first line above.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Need help Selecting, Sorting, Autofitting a range

Get rid of the .Select at the end of the first line of code.
E.g.,

Set rng = NwSht.Range("A1:G8", NwSht.Range("G65536").End(xlUp))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Mr. Clean" wrote in message
om...
Set rng = NwSht.Range("A1:G8",

NwSht.Range("G65536").End(xlUp)).Select
rng.Sort Key1:=Range("A2"), Order1:=xlAscending,

Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,

Orientation:=xlTopToBottom
rng.Columns.AutoFit
NwSht.Range("A1").Select
NwSht.Activate

Not working, what am I doing wrong?

says object required on the first line above.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need help Selecting, Sorting, Autofitting a range

Also

Key1:=Range("A2"),

should be
Key1:=NwSht.Range("A2"),

--
Regards,
Tom Ogilvy

Chip Pearson wrote in message
...
Get rid of the .Select at the end of the first line of code.
E.g.,

Set rng = NwSht.Range("A1:G8", NwSht.Range("G65536").End(xlUp))


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Mr. Clean" wrote in message
om...
Set rng = NwSht.Range("A1:G8",

NwSht.Range("G65536").End(xlUp)).Select
rng.Sort Key1:=Range("A2"), Order1:=xlAscending,

Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,

Orientation:=xlTopToBottom
rng.Columns.AutoFit
NwSht.Range("A1").Select
NwSht.Activate

Not working, what am I doing wrong?

says object required on the first line above.





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 and Selecting dates kesslerjg Excel Discussion (Misc queries) 3 August 4th 09 07:27 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Jim Rech's macro won't work (autofitting merged cells) Ron M. Excel Discussion (Misc queries) 4 March 2nd 06 05:07 PM
linked cell contents not autofitting row height joeeng Excel Discussion (Misc queries) 5 August 2nd 05 07:58 PM
Autofitting a row Josephine Excel Discussion (Misc queries) 2 March 3rd 05 03:37 PM


All times are GMT +1. The time now is 05:41 PM.

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"