PDA

View Full Version : Solved: auto descending order using macro



muzammel
12-08-2009, 08:46 AM
please help me...i'm totaly zero knowledge in VBA...

i have running data from others program and then i extract to excel program..
my problem is...
1. the data not in descending order..
i need to do auto descending order using macro...already try copy and
paste the program but cannot run....
2. the running data is at sheet 1 and i plan to do the auto descending order
at sheet two.

can someone help me...already stuck about one week for this problem...
here i attach sample worksheet for your to add the vba...

thanks
muzammel

hardlife
12-08-2009, 09:19 AM
if me is not wrong with target :hi:

muzammel
12-08-2009, 09:26 AM
thank for the reply...i will try first...any result i will post...thank you very much

muzammel
12-08-2009, 09:57 AM
hardlife...the worksheet is running...thank you... :)I
I have questions..
- if i need to add another data for another column..how should i do...

thanks...

hardlife
12-08-2009, 01:10 PM
muzammel... happy me understood :-) me is happy it works

- what data do You need to add?

- best should be to show input and desired output in attachment

now it copies all data from first sheet (without limit)
and paste all data to second sheet (than sorts data in column B descendig)

Good Night for now, Pavel :hi:

mdmackillop
12-08-2009, 03:32 PM
This gives you the option to set the sort column

Sub sortdata()
Dim Col
Col = InputBox("Column to sort by?")
Sheets("running data").Cells.Copy Sheets("auto desecending").Range("A1")
With ActiveWorkbook.Worksheets("auto desecending")
.Cells.Sort Key1:=.Cells(2, Col), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub


Pavel,
Good working code. Try though, to trim out "Select" which simplifies and speeds up the execution of your code.

muzammel
12-08-2009, 09:13 PM
hai...

here i attach the exactly format that i need to use...
can someone add the program since i'm totaly blind in the programming language...

at "running data" sheet is data i extract from others program..
so i need another sheet for data after sort with descending order...

thanks....

muzammel
12-08-2009, 09:16 PM
This gives you the option to set the sort column

Sub sortdata()
Dim Col
Col = InputBox("Column to sort by?")
Sheets("running data").Cells.Copy Sheets("auto desecending").Range("A1")
With ActiveWorkbook.Worksheets("auto desecending")
.Cells.Sort Key1:=.Cells(2, Col), Order1:=xlDescending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
End Sub

Pavel,
Good working code. Try though, to trim out "Select" which simplifies and speeds up the execution of your code.


If i need to use this program...what should i do...just copy all the above program and then past at VB..
can u assist me...thanks in advance

mdmackillop
12-09-2009, 06:56 AM
Try this

muzammel
12-09-2009, 08:27 AM
Try this

Thank for your help...i will try first and let you know...
thank for your help

muzammel
12-09-2009, 09:06 AM
hai...after test the latest version from mdmackillop...the worksheet is running...:clap::clap::clap:
thank for every one for helping me...:thumb

i have another question...how to mark this thread with "solved"...

found the "solved" button...:doh:

hardlife
12-10-2009, 09:24 AM
Hi mdmackillop,

Thank You for this tip according to
my usage of select, which was not necessary.

happy and sunny day to everybody, pavel:hi: