- Get link
- X
- Other Apps
By
Anandan M
-
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:
- Insert a new column to the right of the column with the folder paths.
- 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. - Copy the formula down the entire column to calculate the number of backslashes in each folder path.
- Insert a new sheet in the workbook and name it "Tree".
- 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".
- In the first cell of each column, enter the corresponding level number. For example, in cell A1, enter "1" for Level 1.
- 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. - Copy the formula across the columns for all levels of the folder path.
- 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.
Anandan is a SharePoint and Microsoft Azure consultant.He is having 9+ years of experience in the web, cloud, Machine Learning, IoT and mobile technology.
He handled multi-platform solution as a consultant with the experience of designing, developing and deploying solutions by leveraging Microsoft, IBM, Apple, and Google technology stack, has played a dynamic role in the development of SharePoint and ML technologies.
He writes articles related to SharePoint Online/On-Premises and Machine Learning.
- Get link
- X
- Other Apps
Comments
Post a Comment