PDA

View Full Version : Vba Code Automatically Sort Large To Small



etheer
06-22-2013, 06:24 PM
Hi

I Need Vba Code Automatically Sort Large To Small

SamT
06-22-2013, 06:32 PM
Range("A:A").Sort(xlDescending)

etheer
06-22-2013, 06:45 PM
Thank you SamT
You can give me full code

SamT
06-22-2013, 08:01 PM
With the information you posted, that is all I can give.

GarysStudent
06-23-2013, 05:31 AM
Here is an example using event code to automatically sort entries in column A.

etheer
06-23-2013, 12:19 PM
Thank you
You can edit Automtically run macro when opening file excel



Private Sub Worksheet_Change(ByVal Target As Range)
Dim N As Long
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
N = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:A" & N).Sort Key1:=Range("A1"), Order1:=xlDescending, Header:=xlYes
End Sub

etheer
06-23-2013, 12:22 PM
when changing cell A in sheet2 automatically sort cell A in sheet1

mancubus
06-24-2013, 02:22 PM
Thank you
You can edit Automtically run macro when opening file excel

Private Sub Worksheet_Change(ByVal Target As Range)
Dim N As Long
If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
N = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1:A" & N).Sort Key1:=Range("A1"), Order1:=xlDescending, Header:=xlYes
End Sub


if you want the macro run when the workbook is opened put it in ThisWorkbook code module with Workbook_Open event.

Private Sub Workbook_Open()
Dim N As Long
With Worksheets("Sheet1")
N = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1:A" & N).Sort Key1:=.Range("A1"), Order1:=xlDescending, Header:=xlYes
End With
End Sub

mancubus
06-24-2013, 02:26 PM
when changing cell A in sheet2 automatically sort cell A in sheet1


goes to the code module of Sheet2
Private Sub Worksheet_Change(ByVal Target As Range)

Dim N As Long

If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub

With Worksheets("Sheet1")
N = .Cells(.Rows.Count, "A").End(xlUp).Row
.Range("A1:A" & N).Sort Key1:=.Range("A1"), Order1:=xlDescending, Header:=xlYes
End With

End Sub

etheer
06-24-2013, 03:44 PM
I used data online in sheet my problem in code i need click on enter in keyword for work code
when change cell online dont work code

mancubus
06-25-2013, 02:11 AM
im not sure i can follow you.

if you run ev_off macro in GarysStudent's file, it will suppress the events. and nothing will happen associated with that event code.

you have to enable events by running ev_on macro.

etheer
06-27-2013, 02:44 PM
don't work code automatically working when click enter in keyboard

Aussiebear
06-27-2013, 03:25 PM
don't work code automatically working when click enter in keyboard

Can you be a little more precise in the information that you currently offer?

Are you entering a value when you click on enter or simply selecting the cell?

etheer
06-27-2013, 03:52 PM
i need when changing cell A in sheet2 automatically sort large to small
in sheet1
please download file

A Sorted Affair2.xlsm


:banghead::banghead::banghead:

Aussiebear
06-27-2013, 11:25 PM
That is significantly different from the initial post, which stated "I Need Vba Code Automatically Sort Large To Small" then moved to "when changing cell A in sheet2 automatically sort cell A in sheet1", which is different to "i need when changing cell A in sheet2 automatically sort large to small in sheet1".