 <p>Where arrList is the list returned by the GetSubnetLocations function in the format above (alphabetized) </p> <pre><code>Dim arrMenu : ReDim arrMenu(-1) Dim arrLocs : ReDim arrLocs(UBound(arrList),1) i = 0 For Each x In arrList 'Also building option list here intCount = Len(x) - Len(Replace(x,"/","")) arrLocs(i,0) = x arrLocs(i,1) = intCount i = i + 1 Next Result.InnerHTML = "" ReDim Preserve arrMenu(UBound(arrMenu)+1) arrMenu(UBound(arrMenu)) = "&lt;ul id=""menu""&gt;" For x = 1 To UBound(arrLocs,1) Step 1 ReDim Preserve arrMenu(UBound(arrMenu)+1) arrMenu(UBound(arrMenu)) = "&lt;li&gt;&lt;a&gt;" &amp; " " &amp; arrLocs(x,0) &amp; "&lt;/a&gt;&lt;/li&gt;" Next For j = 1 To UBound(arrMenu) If arrLocs(j,1) &gt; arrLocs(j-1,1) Then arrMenu(j-1) = Replace(arrMenu(j-1),"&lt;/li&gt;","&lt;ul style=""display:none""&gt;") End If If arrLocs(j,1) &lt; arrLocs(j-1,1) Then For x = 1 To arrLocs(j-1,1) - arrLocs(j,1) arrMenu(j-1) = arrMenu(j-1) &amp; "&lt;/li&gt;" Next End If Next ReDim Preserve arrMenu(UBound(arrMenu)+1) arrMenu(UBound(arrMenu)) = "&lt;/ul&gt;" strMenu = "" For Each n In arrMenu strMenu = strMenu &amp; n Next Result.InnerHTML = strMenu </code></pre>