Need help updating sort automatically, but only if a cell has a number
I am trying to automatically sort by date in my excel document. But only update if there is a number (0 or 1) in the Q column of the row I am making a change in.
Here is what I've got so far.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Range(ActiveCell, "Q2:Q1000")) Is Nothing Then
Range("g1").Sort Key1:=Range("g2"), Order1:=xlAscending, Header:=xlYes, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End If
End Sub
When I run it I get Argument not optional. What I am expecting is, if there is nothing in the Q column of the row I am updating the date in (which is g column), then do nothing, but if there is a number (0 or 1), then resort the document.