VBA Tree View from string

后端 未结 4 1200
梦毁少年i
梦毁少年i 2020-12-18 12:59

I would like to get tree view using excel vba.I have many String likes this

      /folderOne/fileOne
      /folderTwo/fileThree
      /folderOne/fileTwo
             


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-18 13:51

    ok assuming your data is in Column A, try this:

    Option Explicit
    
    Sub test()
    
    Dim rng As Range, cel As Range
    
    Set rng = ThisWorkbook.Sheets("Sheet1").Range("A1", _
                ThisWorkbook.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Address)
    
    rng.TextToColumns rng.Range("A1"), , , , , , , , True, "/"
    
    Set rng = ThisWorkbook.Sheets("Sheet1").Range("B1", _
                ThisWorkbook.Sheets("Sheet1").Range("B" & Rows.Count).End(xlUp).Address)
    
    For Each cel In rng
        If cel.Row <> 1 Then If cel.Value = cel.Offset(-1, 0).Value Then cel.ClearContents
    Next
    
    End Sub
    

    Hope this get's you started somehow.

提交回复
热议问题