ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Manually editing Sort function in VBA (https://www.excelbanter.com/excel-programming/307928-manually-editing-sort-function-vba.html)

havocdragon

Manually editing Sort function in VBA
 
I Have beem attempting to manually do my own sorting in VBA, but to no
avail. So I record a macro that sorts, and that works fine. BUT, if I want
to edit it, it no longer works, also, If I manually type the EXACT same
arguement , it doesnt work. The only thing that works so far in VBA, is just
running the macro and cutting it and pasting it to my macro.

Here is what excel records

Rows("1:11").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending, Key2:=Range("B2") _
, Order2:=xlDescending, Header:=xlYes, OrderCustom:=1,
MatchCase:=False _
, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:= _
xlSortNormal

Frank Stone

Manually editing Sort function in VBA
 
I have had the situation where i needed to sometimes do
multiple sorts. what i did was have a sort macro for each
way i needed to sort. that way i didn't need to edit the
sort macro. in one file i had the sort macros assigned to
2 buttons on the sheets. the user could sort one way by
click one button then sort the other way by click the
other button.

-----Original Message-----
I Have beem attempting to manually do my own sorting in

VBA, but to no
avail. So I record a macro that sorts, and that works

fine. BUT, if I want
to edit it, it no longer works, also, If I manually

type the EXACT same
arguement , it doesnt work. The only thing that works so

far in VBA, is just
running the macro and cutting it and pasting it to my

macro.

Here is what excel records

Rows("1:11").Select
Selection.Sort Key1:=Range("A2"), Order1:=xlDescending,

Key2:=Range("B2") _
, Order2:=xlDescending, Header:=xlYes,

OrderCustom:=1,
MatchCase:=False _
, Orientation:=xlTopToBottom,

DataOption1:=xlSortNormal,
DataOption2:= _
xlSortNormal
.



All times are GMT +1. The time now is 01:41 PM.

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