MistakesWereMade
Board Regular
- Joined
- May 22, 2019
- Messages
- 103
I would like to sort cell values in a single column from smallest to largest. However, I can't seem to make my code work. I would like for my column to constantly sort the column when it is updated via its formula.
Below is my code. I made an If statement so that whenever the range of cells are updated/changed, it will trigger the sorting.
Below is my code. I made an If statement so that whenever the range of cells are updated/changed, it will trigger the sorting.
Code:
Dim Val As String
Val = Range("C2:C501").Value
Private Sub SortColumnC()
If Range("C2:C501") <> Val Then
Range("C2:C501").Sort Key1:=Range("C1"), Order1:=xlAscending, Header:=xlYes
Val = Range("C2:C501").Value
End If
End Sub