-
Jul 10th, 2017, 06:23 AM
#1
Thread Starter
Registered User
Help VB sorting
when im using this, I can get all the data 1 to 11 from excel
'ws.Range("details").Sort _
'Key1:=ws.Range("srsno"), Order1:=xlascending, Header:=xlNo
ItemNo Data
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
but when using this i can only get 11 to 2 correct data, 1 have the same data of 11
'ws.Range("details").Sort _
'Key1:=ws.Range("srsno"), Order1:=xlDescending, Header:=xlNo
11 11
10 10
9 9
8 8
7 7
6 6
5 5
4 4
3 3
2 2
1 11
-
Jul 10th, 2017, 07:10 AM
#2
Re: Help VB sorting
Welcome myx!
However, I am afraid you have posted in the wrong area of this forum. I believe this thread belongs in the Office Development section, as nothing about resembles any VB6 (and earlier) code. I'll flag the moderators and they may move it.
If you ARE using VB6, then post again stating so...but, I suspect you may be using VBA.
Sam
-
Jul 10th, 2017, 10:09 AM
#3
Re: Help VB sorting
Thread moved to Office Development, which is the right place for VBA/Excel questions.
My usual boring signature: Nothing
-
Jul 10th, 2017, 10:17 AM
#4
Re: Help VB sorting
How are you setting range "srsno" in both cases?
-
Jul 10th, 2017, 04:36 PM
#5
Re: Help VB sorting
How are you setting range "srsno"
not sure that matters, as long as it is any cell(s) in the column to be sorted by, should still work the same, even if not in the range to be sorted
certainly it would be good to know the addresses of both named ranges, to see if any cells are missed
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|