Hi
I Need Vba Code Automatically Sort Large To Small
Printable View
Hi
I Need Vba Code Automatically Sort Large To Small
Range("A:A").Sort(xlDescending)
Thank you SamT
You can give me full code
With the information you posted, that is all I can give.
Here is an example using event code to automatically sort entries in column A.
Thank you
You can edit Automtically run macro when opening file excel
Code: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
when changing cell A in sheet2 automatically sort cell A in sheet1
if you want the macro run when the workbook is opened put it in ThisWorkbook code module with Workbook_Open event.Quote:
Originally Posted by etheer
[VBA]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
[/VBA]
goes to the code module of Sheet2Quote:
Originally Posted by etheer
[VBA]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
[/VBA]
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
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.
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?Quote:
Originally Posted by etheer
Are you entering a value when you click on enter or simply selecting the cell?
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:
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".