Hi all,

I use the following code for sorting named ranges by hour. But it sorts all the ranges in the worksheet and I only want the ranges that start with 'mission'.

Can the
For Each NamedRng In ActiveWorkbook.Names
be changed so that it only sorts the ranges in the workbook that start with mission?



'Startrij voor de lijst instellen = Rij 1 fungeert als "hoofding"
R = 2
'Ranges naar lijst kopiëren - Opdracht en uur
For Each NamedRng In ActiveWorkbook.Names
    LijstWks.Cells(R, 1) = NamedRng.Name
    LijstWks.Cells(R, 2) = NamedRng.RefersToRange.Cells(1, 2)
    R = R + 1
Next NamedRng
    
'Ranges sorteren in de lijst
R = R - 1
Set ListRng = LijstWks.Range("A2").Resize(R - 1, 2)
ListRng.Sort Key1:=ListRng.Cells(1, 2), Order1:=xlAscending
       
'Ranges kopiëren naar SortWks
R = 1
For I = 1 To ListRng.Rows.Count
    Set Rng = ActiveWorkbook.Names(ListRng.Cells(I, 1).Text).RefersToRange
    Rng.Cut Destination:=SortWks.Cells(R, 1)
    R = R + Rng.Rows.Count
    
Next I


'Opdrachten naar detail kopiëren
R = 1
Worksheets("SortWks").Range("A1:U493").Cut Destination:=Worksheets("detail").Range("A5:U497")