Hi all,
I have a simplified version of a sheet I'm working with below showing the data as it is, and how I'd like it to be....
CURRENTLY...
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Employee
[/TD]
[TD]Blank Values in Hierarchy
[/TD]
[TD]Line 1 Manager
[/TD]
[TD]Line 2 Manager
[/TD]
[TD]Line 3 Manager
[/TD]
[TD]Line 4 Manager
[/TD]
[/TR]
[TR]
[TD]Employee 1
[/TD]
[TD]2
[/TD]
[TD]Manager B
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Employee 2
[/TD]
[TD]3
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Employee 3
[/TD]
[TD]1
[/TD]
[TD]Manager C
[/TD]
[TD]Manager B
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Employee 4
[/TD]
[TD]2
[/TD]
[TD]Manager D
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Employee 5
[/TD]
[TD]3
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
HOW I'D LIKE IT TO BE...
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Employee
[/TD]
[TD]Blank Values in Hierarchy
[/TD]
[TD]Line 1 Manager
[/TD]
[TD]Line 2 Manager
[/TD]
[TD]Line 3 Manager
[/TD]
[TD]Line 4 Manager
[/TD]
[/TR]
[TR]
[TD]Employee 1
[/TD]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Manager B
[/TD]
[TD]Manager A
[/TD]
[/TR]
[TR]
[TD]Employee 2
[/TD]
[TD]3
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Manager A
[/TD]
[/TR]
[TR]
[TD]Employee 3
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD]Manager C[/TD]
[TD]Manager B
[/TD]
[TD]Manager A
[/TD]
[/TR]
[TR]
[TD]Employee 4
[/TD]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Manager D
[/TD]
[TD]Manager A
[/TD]
[/TR]
[TR]
[TD]Employee 5
[/TD]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Manager A[/TD]
[/TR]
</tbody>[/TABLE]
Essentially what I'm trying to do is "right-align" the manager hierarchy by moving the hierarchy values to the right depending on the amount of blank values (which I've got a count of for each row in column B). For example, in row 2 (Employee 1) I want to insert 2 cells at C2 to move the hierarchy along by 2. However in row 4 (Employee 3), I'd only want to insert 1 cell at C4 as the data only needs to move along by 1 cell as there is only 1 blank value etc. etc.
Sadly it's not possible to do this manually as I have a sheet with over 1,000 rows so I'm hoping that there is a quick VBA solution that could go through each row by row, checking the value in column B, and inserting the appropriate number of cells at C2, C3, C4 etc. in order to move the data along to "right align" it if that makes sense.
I'd appreciate any help or solution that could be provided, or if anyone can think of a more elegant solution I'd love to hear it!
Thanks in advance!
I have a simplified version of a sheet I'm working with below showing the data as it is, and how I'd like it to be....
CURRENTLY...
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Employee
[/TD]
[TD]Blank Values in Hierarchy
[/TD]
[TD]Line 1 Manager
[/TD]
[TD]Line 2 Manager
[/TD]
[TD]Line 3 Manager
[/TD]
[TD]Line 4 Manager
[/TD]
[/TR]
[TR]
[TD]Employee 1
[/TD]
[TD]2
[/TD]
[TD]Manager B
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Employee 2
[/TD]
[TD]3
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Employee 3
[/TD]
[TD]1
[/TD]
[TD]Manager C
[/TD]
[TD]Manager B
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Employee 4
[/TD]
[TD]2
[/TD]
[TD]Manager D
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Employee 5
[/TD]
[TD]3
[/TD]
[TD]Manager A
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
HOW I'D LIKE IT TO BE...
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Employee
[/TD]
[TD]Blank Values in Hierarchy
[/TD]
[TD]Line 1 Manager
[/TD]
[TD]Line 2 Manager
[/TD]
[TD]Line 3 Manager
[/TD]
[TD]Line 4 Manager
[/TD]
[/TR]
[TR]
[TD]Employee 1
[/TD]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Manager B
[/TD]
[TD]Manager A
[/TD]
[/TR]
[TR]
[TD]Employee 2
[/TD]
[TD]3
[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Manager A
[/TD]
[/TR]
[TR]
[TD]Employee 3
[/TD]
[TD]1
[/TD]
[TD][/TD]
[TD]Manager C[/TD]
[TD]Manager B
[/TD]
[TD]Manager A
[/TD]
[/TR]
[TR]
[TD]Employee 4
[/TD]
[TD]2
[/TD]
[TD][/TD]
[TD][/TD]
[TD]Manager D
[/TD]
[TD]Manager A
[/TD]
[/TR]
[TR]
[TD]Employee 5
[/TD]
[TD]3[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]Manager A[/TD]
[/TR]
</tbody>[/TABLE]
Essentially what I'm trying to do is "right-align" the manager hierarchy by moving the hierarchy values to the right depending on the amount of blank values (which I've got a count of for each row in column B). For example, in row 2 (Employee 1) I want to insert 2 cells at C2 to move the hierarchy along by 2. However in row 4 (Employee 3), I'd only want to insert 1 cell at C4 as the data only needs to move along by 1 cell as there is only 1 blank value etc. etc.
Sadly it's not possible to do this manually as I have a sheet with over 1,000 rows so I'm hoping that there is a quick VBA solution that could go through each row by row, checking the value in column B, and inserting the appropriate number of cells at C2, C3, C4 etc. in order to move the data along to "right align" it if that makes sense.
I'd appreciate any help or solution that could be provided, or if anyone can think of a more elegant solution I'd love to hear it!
Thanks in advance!