Sort Alphabetic and Automatically Update When Added Data

muhammad susanto

Well-known Member
Joined
Jan 8, 2013
Messages
2,102
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
hi all....

how to automatically sort and update asc to desc (alphabetic)
this layout :

[TABLE="class: tableizer-table"]
<thead>[TR="class: tableizer-firstrow"]
[TH]data[/TH]
[TH]expected result[/TH]
[/TR]
</thead><tbody> [TR]
[TD]zzz[/TD]
[TD]b[/TD]
[/TR]
[TR]
[TD]zzz[/TD]
[TD]dddddd[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD]dddddd[/TD]
[/TR]
[TR]
[TD]dddddd[/TD]
[TD]dddddd[/TD]
[/TR]
[TR]
[TD]dddddd[/TD]
[TD]dddddd[/TD]
[/TR]
[TR]
[TD]dddddd[/TD]
[TD]s[/TD]
[/TR]
[TR]
[TD]dddddd[/TD]
[TD]s[/TD]
[/TR]
[TR]
[TD]s[/TD]
[TD]s[/TD]
[/TR]
[TR]
[TD]s[/TD]
[TD]zzz[/TD]
[/TR]
[TR]
[TD]s[/TD]
[TD]zzz[/TD]
[/TR]
</tbody>[/TABLE]


thanks

m.susanto
 
Last edited:

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Assuming your data are in col A starting in A2, put this in the sheet's code:

To install sheet code:
1. Right-click the worksheet tab you want to apply it to and choose 'View Code'. This will open the VBE window.
2. Copy the code below from your browser window and paste it into the white space in the VBE window.
3. Close the VBE window and Save the workbook. If you are using Excel 2007 or a later version do a SaveAs and save it as a macro-enabled workbook (.xlsm file extension).
4. Make sure you have enabled macros whenever you open the file or the code will not run.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row)) Is Nothing Then
    Application.EnableEvents = False
    Range("A2:A" & Cells(Rows.Count, "A").End(xlUp).Row).Sort key1:=[A2], order1:=xlAscending
    Application.EnableEvents = True
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top