ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Need help Selecting, Sorting, Autofitting a range (https://www.excelbanter.com/excel-programming/286199-need-help-selecting-sorting-autofitting-range.html)

Mr. Clean[_2_]

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.

Chip Pearson

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.




Tom Ogilvy

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.







All times are GMT +1. The time now is 08:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com