Juddman79
New Member
- Joined
- Feb 17, 2020
- Messages
- 31
- Office Version
- 2016
- Platform
- Windows
Apologies if this question have been answered elsewhere. I'm a complete novice when it comes to VBA Code but I've been trying to sort data alphabetically (Column A) which I achieved with the below code.
The data range of the sheet is A3 to W100 (Rows 1 and 2 are headers). Is it possible to automatically sort by Column A (Location - alphabetically) first and then to sort the data by Column F (Arrival Date - Ascending), but only when both of these cells are populated with data?
I did have a second question but that issue seems to have rectified itself.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("A:A")) Is Nothing Then
Range("A1").Sort Key1:=Range("A3"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub
The data range of the sheet is A3 to W100 (Rows 1 and 2 are headers). Is it possible to automatically sort by Column A (Location - alphabetically) first and then to sort the data by Column F (Arrival Date - Ascending), but only when both of these cells are populated with data?
I did have a second question but that issue seems to have rectified itself.