This is my first macro written by me without any help taken from else.
Actually,I want to sort Column-I,If the figure is one ( 1) then sort according to ascending order of col.B.
And if the figure is 'zero' ( 0 or -) then sort according to ascending order of col.B.after sorting to above step i.e. digit '1'.
But the error are coming:-
Row No.1373 that should come row no.1386
Row No.1374 that should come at row no.1388
row no.1376 that should come at row no.7
Can anyone help me what are my mistakes that are providing result unwanted?
Please refre my attach file for more clarification.
Result is not found from proper sorting
-
- 3StarLounger
- Posts: 354
- Joined: 27 Oct 2013, 15:11
- Location: Gurgaon INDIA
Result is not found from proper sorting
Regards
Pradeep Kumar Gupta
INDIA
Pradeep Kumar Gupta
INDIA
-
- Administrator
- Posts: 78651
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Result is not found from proper sorting
You use End(xlDown) to determine the last row. But End(xlDown) stops when it encounters a blank cell/row. Since row 1372 is completely blank, only rows from 6 to 1371 are sorted, and all rows below that are ignored.
You could use the following instead:
LastRow will be 1387, the real last used row. The range to sort becomes Range("B6:Q" & LastRow)
You could use the following instead:
Code: Select all
Dim LastRow As Long
LastRow = Range("B" & Rows.Count).End(xlUp).Row
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 354
- Joined: 27 Oct 2013, 15:11
- Location: Gurgaon INDIA
Re: Result is not found from proper sorting
Thanks for suggestion.
Regards
Pradeep Kumar Gupta
INDIA
Pradeep Kumar Gupta
INDIA