I need to make a simple sheet for a sports event, but I'm new to macro's and VB.
Column A will have a person's rank (#1, 2, 3 etc.)
Column B will have their name
Column C will have their score.
I have found a macro to auto-sort when I enter a person's score.
Now, there are two issues I found with it and as I'm new, I can't seem to find the problem.
1: If I enter no name and only a score, it sorts the score anyway. I only want scores with a name to sort. How can I achieve this?
2: The ranking in column A should remain in that order, so we can tell a person his rank (ex. you got in 10th place). Right now, when I enter a score, it sorts it all (so the values in A and B stay with 'their' score. What I want is that the score (col.C) is sorted with the name (col.B) staying with it, but the rank (col.A) stays in the same order as it was (so not tied to the B or C values). How can I achieve this?
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Not Intersect(Target, Range("B:C")) Is Nothing Then
Range("C1").Sort Key1:=Range("C2"), _
Order1:=xlDescending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom
End If
End Sub