To convert a column of folder paths into a tree structure of rows, you can use a combination of Excel formulas and VBA code. Here are the steps to follow:

  1. Insert a new column to the right of the column with the folder paths.
  2. In the first cell of the new column, enter the formula =LEN(A1)-LEN(SUBSTITUTE(A1,"\","")), where A1 is the first cell in the column with the folder paths. This formula calculates the number of backslashes in the folder path.
  3. Copy the formula down the entire column to calculate the number of backslashes in each folder path.
  4. Insert a new sheet in the workbook and name it "Tree".
  5. In the "Tree" sheet, create headers for the columns "Level 1", "Level 2", "Level 3", etc. up to the maximum number of levels in your folder paths. For example, if your folder paths have a maximum of 3 levels, create columns for "Level 1", "Level 2", and "Level 3".
  6. In the first cell of each column, enter the corresponding level number. For example, in cell A1, enter "1" for Level 1.
  7. In cell A2 of the "Tree" sheet, enter the formula =LEFT(Sheet1!A2,FIND("|",SUBSTITUTE(Sheet1!A2,"\","|",B2))-1), where Sheet1!A2 is the first cell in the column with the folder paths, and B2 is the level number in the "Tree" sheet. This formula extracts the first level of the folder path.
  8. Copy the formula across the columns for all levels of the folder path.
  9. Copy the formulas down for all rows in the "Tree" sheet to create a tree structure of rows for all folder paths.

Note: To make this process more automated, you can create a VBA macro that loops through the column with the folder paths and populates the "Tree" sheet with the appropriate level values.

Comments

Popular posts from this blog

Sharepoint 2013-Minimal Download Strategy.

Bulk update and delete using SPservice in SharePoint