Kym_beginner_in_VBA
New Member
- Joined
- May 21, 2022
- Messages
- 7
- Office Version
- 365
- Platform
- Windows
Hi
I've got a simple address table of 5 columns, which i have a macro running too auto sort it by name ascending. however to avoid it sorting before i fill in all the fields, i have to type the name in last.
is there a way to only make the auto sort happen if data is entered into collumn 'E' which is my postcode column?
here is the code that i found online which works great, but now i'd really like to enter all data fields before the table autosorts into a name order. so id like a condition for the E column (which just happens to be the postcode column) only as D does not always have a value abyway
I've got a simple address table of 5 columns, which i have a macro running too auto sort it by name ascending. however to avoid it sorting before i fill in all the fields, i have to type the name in last.
is there a way to only make the auto sort happen if data is entered into collumn 'E' which is my postcode column?
here is the code that i found online which works great, but now i'd really like to enter all data fields before the table autosorts into a name order. so id like a condition for the E column (which just happens to be the postcode column) only as D does not always have a value abyway
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If ActiveSheet.Range("E2").Value = "" Then Exit Sub
Range("A1").Sort Key1:=Range("A2"), _
Order1:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub
Last edited by a moderator: