ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Sorting a sheet in VBA (https://www.excelbanter.com/excel-discussion-misc-queries/270613-sorting-sheet-vba.html)

Sonnich Jensen

Sorting a sheet in VBA
 
Hi

I seem to have problems with this - I have a sheet of 2 coloums as

A = string, B = number, given as =1+2+3+.....

Now, I want to sort by the number, therefo

sh2.Range("B:B").Sort Key1:=sh2.Range("B:B"), Order1:=xlAscending,
Orientation:=xlSortRows
sh2 = worksheet

However, that does not really work.... what do I do wrong?

WBR
Sonnich

Jim Cone[_2_]

Sorting a sheet in VBA
 
What does "does not really work" mean?
How is "sh2" established as a worksheet?

Do you do something like...
Dim sh2 as Worksheet
Set sh2 = Worksheets("Sludge")
--
Jim Cone
Portland, Oregon USA .
http://www.contextures.com/excel-sort-addin.html .
(editorial review of special sort excel add-in (30 ways to sort)




"Sonnich Jensen"

wrote in message
...
Hi

I seem to have problems with this - I have a sheet of 2 coloums as

A = string, B = number, given as =1+2+3+.....

Now, I want to sort by the number, therefo

sh2.Range("B:B").Sort Key1:=sh2.Range("B:B"), Order1:=xlAscending,
Orientation:=xlSortRows
sh2 = worksheet

However, that does not really work.... what do I do wrong?

WBR
Sonnich




Dave Peterson[_2_]

Sorting a sheet in VBA
 
Maybe you want to sort both columns A and B???

sh2.range("a:b").sort .....



On 10/24/2011 10:22, Sonnich Jensen wrote:
Hi

I seem to have problems with this - I have a sheet of 2 coloums as

A = string, B = number, given as =1+2+3+.....

Now, I want to sort by the number, therefo

sh2.Range("B:B").Sort Key1:=sh2.Range("B:B"), Order1:=xlAscending,
Orientation:=xlSortRows
sh2 = worksheet

However, that does not really work.... what do I do wrong?

WBR
Sonnich


--
Dave Peterson


All times are GMT +1. The time now is 06:35 PM.

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