ExcelBanter

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

Farhad

Sorting a sheet by VBA
 
Hi,

i need to sort my worksheet in my VBA code i used the code below but it
doesn't work:

RCnt = Cells(Rows.Count, 2).End(xlUp).Row
Range("A1:Q" & Trim(Str(RCnt + 2))).Sort Key1:=Range("A2"),
Order1:=xlAscending, Key2:=Range _
("B2"), Order2:=xlAscending, Key3:=Range("E2"), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal

any help would be appreciated.

Thanks,
--
Farhad Hodjat

Toppers

Sorting a sheet by VBA
 
What doesn't work? It appeared to work OK for me.

"Farhad" wrote:

Hi,

i need to sort my worksheet in my VBA code i used the code below but it
doesn't work:

RCnt = Cells(Rows.Count, 2).End(xlUp).Row
Range("A1:Q" & Trim(Str(RCnt + 2))).Sort Key1:=Range("A2"),
Order1:=xlAscending, Key2:=Range _
("B2"), Order2:=xlAscending, Key3:=Range("E2"), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal

any help would be appreciated.

Thanks,
--
Farhad Hodjat


Farhad

Sorting a sheet by VBA
 
Hi,

Thank you for your reply, it suppose to sort my sheet based on the condition
i determined but nothing would happen to my sheet.

Thanks,
--
Farhad Hodjat


"Toppers" wrote:

What doesn't work? It appeared to work OK for me.

"Farhad" wrote:

Hi,

i need to sort my worksheet in my VBA code i used the code below but it
doesn't work:

RCnt = Cells(Rows.Count, 2).End(xlUp).Row
Range("A1:Q" & Trim(Str(RCnt + 2))).Sort Key1:=Range("A2"),
Order1:=xlAscending, Key2:=Range _
("B2"), Order2:=xlAscending, Key3:=Range("E2"), Order3:=xlAscending, _
Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal

any help would be appreciated.

Thanks,
--
Farhad Hodjat



All times are GMT +1. The time now is 07:22 AM.

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