G
Guest
I know this code automatically sorts a column in ascending order. But what
changes would you have to make to it to get it to sort a range of colums say
from A1 to F1 or maybe more?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim whereIam As Range
Set whereIam = ActiveCell
If Intersect(Target, Range("B:B")) Is Nothing Then
Exit Sub
End If
Range("B1:" & Range("B1").End(xlDown).Address).Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending
'and back to where you started
whereIam.Select
End Sub
changes would you have to make to it to get it to sort a range of colums say
from A1 to F1 or maybe more?
Private Sub Worksheet_Change(ByVal Target As Range)
Dim whereIam As Range
Set whereIam = ActiveCell
If Intersect(Target, Range("B:B")) Is Nothing Then
Exit Sub
End If
Range("B1:" & Range("B1").End(xlDown).Address).Select
Selection.Sort Key1:=Range("B1"), Order1:=xlAscending
'and back to where you started
whereIam.Select
End Sub