I have an Excel sheet with variable rows but 5 columns. The final column has comma separated values of varying length.
I have been trying to write a "For Loop" to Transpose this data into Rows while retaining the Data in existing Columns A:D.
Source Data Sample
| User ID | User name | Group ID | Group name | Effective permissions | | | | | |
|---------|-----------|----------|------------|-----------------------|------|------|------|------|------|
| 1 | Adam | 100 | Active | ABCD | RFGE | ERTY | EDFR | | |
| 2 | Bryan | 100 | Bold | IFEU | WASD | WASF | TGRE | YMUN | TYBN |
| 3 | Charles | 100 | Charity | IFLL | ERTY | WSDF | XKLS | | |
| 4 | David | 100 | Danger | IFEU | UNBY | RVBT | ZXCV | XCVB | VBNM |
Output Data Example
| User ID | User name | Group ID | Group name | Effective permissions |
|---------|-----------|----------|------------|-----------------------|
| 1 | Adam | 100 | Active | ABCD |
| 1 | Adam | 100 | Active | RFGE |
| 1 | Adam | 100 | Active | ERTY |
| 1 | Adam | 100 | Active | EDFR |
| 2 | Bryan | 100 | Bold | IFEU |
| 2 | Bryan | 100 | Bold | WASD |
| 2 | Bryan | 100 | Bold | WASF |
| 2 | Bryan | 100 | Bold | TGRE |
| 2 | Bryan | 100 | Bold | YMUN |
| 2 | Bryan | 100 | Bold | TYBN |
| 3 | Charles | 100 | Charity | IFLL |
| 3 | Charles | 100 | Charity | ERTY |
| 3 | Charles | 100 | Charity | WSDF |
| 3 | Charles | 100 | Charity | XKLS |
| 4 | David | 100 | Danger | IFEU |
| 4 | David | 100 | Danger | UNBY |
| 4 | David | 100 | Danger | RVBT |
| 4 | David | 100 | Danger | ZXCV |
| 4 | David | 100 | Danger | XCVB |
| 4 | David | 100 | Danger | VBNM |
Any help you could provide would be greatly appreciated.
**I have completed VBA projects in the past, however I have usually been able to piece together previous examples to achieve my goal...learning along the way.
If someone could show me how to adapt the below code so that each of the values in my first 4 columns are copied down that would be great.
Sub Test()
Set Rng = Sheets("Test").Range("D2:D15")
Set Rng_output = Sheets("Test2").Range("A2")
For i = 1 To Rng.Cells.Count
Set rng_values = Range(Rng.Cells(i).Offset(0, 1), Rng.Cells(i).End(xlToRight))
If rng_values.Cells.Count < 16000 Then
For j = 1 To rng_values.Cells.Count
Rng_output.Value = Rng.Cells(i).Value
Rng_output.Offset(0, 1).Value = rng_values.Cells(j).Value
Set Rng_output = Rng_output.Offset(1, 0)
Next j
End If
Next i
End Sub