AUTO SORT

apgmin

Board Regular
Joined
Mar 1, 2010
Messages
139
Office Version
  1. 2013
Platform
  1. Windows
In Cells T4:T500, I make the user fill the donors name, I already have a data validation for these cells to prevent duplicate entry

Now in Cells A4:A5000, I use the data validation for list range T4:t500

Can anyone please suggest a formula for T4:T500 such that when ever the user fills the donors name in this range, it gets auto sorted when pressed enter after entry, so that it will be easy for him to select the same from the list when filling Cells A4:A5000
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
I think you need VBA :
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count <> 1 Then
    Exit Sub
ElseIf Not Intersect(Target, [T4:T500]) Is Nothing Then
    [T4:T500].Sort Key1:=[T4], Order1:=xlAscending, Header:=xlNo
End If
End Sub
 
Upvote 0
I think you need VBA :
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count <> 1 Then
    Exit Sub
ElseIf Not Intersect(Target, [T4:T500]) Is Nothing Then
    [T4:T500].Sort Key1:=[T4], Order1:=xlAscending, Header:=xlNo
End If
End Sub
there are 3 sheets in the file, I pasted the above VB as a module on the worksheet ( not under individual sheets ) and saved the file as macro enabled. It is not working, The cells T4:T500 are in the sheet named "Receipts", DO I need to make any changes in the above or insert the VB module in the said sheet, Tried with the following also , still not working

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count <> 1 Then
Exit Sub
ElseIf Not Intersect(Target, ['RECEIPTS'!T4:T500]) Is Nothing Then
['RECEIPTS'!T4:T500].Sort Key1:=[T4], Order1:=xlAscending, Header:=xlNo
End If
End Sub
 
Upvote 0
Put it in the Receipts sheet module. Don't make any changes to the code.
 
Upvote 0
Put it in the Receipts sheet module. Don't make any changes to the code.
still not working, DO I have to put some command or it will autosort after in enter the next entry in the list?
 
Upvote 0
It will auto-sort after you make an entry to a single cell in T4:T500.
 
Upvote 0
Sorry to bother you repeatedly, but can you tell me what I am doing wrong?
I pressed ALT+F11, then Insert module after selecting the kali mandir receipt sheet, pasted the code in the module and saved, then saved file as macro enabled file
 

Attachments

  • Screenshot_1.jpg
    Screenshot_1.jpg
    118.6 KB · Views: 5
  • Screenshot_2.jpg
    Screenshot_2.jpg
    12.2 KB · Views: 7
Upvote 0
Check :
- the code is in correct sheet module (i.e. the sheet containing the T4:T500 list)
- your macro settings allow macros to run
- if still no good, try closing Excel and re-opening (in case event procedures have been disabled)
- try putting a breakpoint against the first line of the macro to see if is being triggered
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,701
Members
448,980
Latest member
CarlosWin

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