ashgull80
01-17-2014, 08:27 AM
Hi
I have a user form that i use to add a companys details to a sheet.
when i enter the data i would like to sort the companys so they are in order.
this is the code i have so far but this sorts a static range of cells, but i need it to sort the new entry aswell.
Sheets("Payee").Select
Range("B2").Select
ActiveWorkbook.Worksheets("Payee").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Payee").Sort.SortFields.Add Key:=Range("B2"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Payee").Sort
.SetRange Range("B2:C20")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
thanks ash
I have a user form that i use to add a companys details to a sheet.
when i enter the data i would like to sort the companys so they are in order.
this is the code i have so far but this sorts a static range of cells, but i need it to sort the new entry aswell.
Sheets("Payee").Select
Range("B2").Select
ActiveWorkbook.Worksheets("Payee").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Payee").Sort.SortFields.Add Key:=Range("B2"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Payee").Sort
.SetRange Range("B2:C20")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
thanks ash