The code does that it is supposed to do but it should also work when I add a person to the list. So the problem is in the first block
I tried changing the 3th line to xldown but this does not work.
Selection.AutoFill Destination:=Range("C2:xlDown")
I tried Googling the solution but only got more confused. The explaination of what the code does is below the code.
Full code:
Sub btn_SortLastName()
'Add content of column B into colum C in lowercase
   Range("C2").Select
   ActiveCell.FormulaR1C1 = "=LOWER(RC[-1])"
   Selection.AutoFill Destination:=Range("C2:C26")
'Copy selection
   Range("C2").Select
   Range(Selection, Selection.End(xlDown)).Select
   Selection.Copy
'Paste selection without formating and remove spaces
   Selection.PasteSpecial Paste:=xlPasteValues
   Selection.Replace What:=" ", Replacement:=""
'Sort in decending order
   Range("C1") = "Index"
   Columns("A:C").Sort key1:=Range("C2"), _
   order1:=xlAscending, Header:=xlYes
'Hide column C and set title on C1
   Columns("C").Select
   Selection.EntireColumn.Hidden = True
   Range("C1").Value = "Hidden"
End Sub
In Dutch there are a lot of last names that are separated by spaces, I want to remove the spaces copy them into a hidden column and transform them into lowercase and sort them.
Example:
B2:De Wolf    C2:dewolf
B3:De Bisscop C3:debisscop
 
     
    