Private Sub Worksheet_Change(ByVal Target As Range)
Application.ScreenUpdating = False
If Not Intersect(Target, Range("B2:B1000")) Is Nothing Then
With ActiveWorkbook.Worksheets("Sheet1")
.Range("A2:B1000").Sort Key1:=.Range("B2")
End With
End If
Application.ScreenUpdating = True
End Sub
Untested:
Code:Private Sub Worksheet_Change(ByVal Target As Range) Application.ScreenUpdating = False If Not Intersect(Target, Range("B2:B1000")) Is Nothing Then With ActiveWorkbook.Worksheets("Sheet1") .Range("A2:B1000").Sort Key1:=.Range("B2") End With End If Application.ScreenUpdating = True End Sub
Thanks for your replies,
yes something similar it needs to search the value in Column and when that value found assign a number to it in Sort column
if it finds A then put 1 into sort column and if it finds B put 2 into sort column
Hi Debraj,Can you please upload a sample file.. with expected output..
With this small data view, its really hard to decide![]()
Hi Luke,This looks less like an actual sorting problem them, and more like a lookup type problem. You want to give a list of values like A-E, and get an output of 1-5? This formula could do it nicely:
=CODE(UPPER(A2))-64
Hi Somendra,Hi exceluser,
If your problem, as indicated by @Luke M , is to get a value based on A-E, say 1 for A, 2 for B and so on, than Luke formula is working fine. You need to drag the formula in Column B till your requirement and as soon as Column A will receive an alphabet it will display the sort order code.
May be the formula should be surrounded by an IFERROR to display a blank if column A is blank, something like below.
=IFERROR(CODE(UPPER((A3)))-64,"")
Regards,
Hi Somendra,@exceluser
The formula given by @Luke M was based on the data your provided. It will not work for the words that you gave now. I suppose here column is not a problem. What will be the sort order for these words? Is there any logic behind giving sort order?
Kindly, explain your requirement in more details.
Regards,
SOMENDRA MISRA said:What will be the sort order for these words? Is there any logic behind giving sort order?
Sort order is fixed for these@exceluser
You did not explained this part. If there is no logic and just the words are assigned arbitary these values say 1 for sit , 2 for jump and so on, and it will remain the same order, you can create a master table with all the words and sort order assigned to them. Than you can use VLOOKUP formula to get sort order automatically in column AF.
Regards,
Thanks Somendra