I'm new to VBA a need some help with the code.
I have a large spreadsheet with several thousands of rows with a unique_ID per row and from 7 to 65 answers to the questions. I need to split this rows by id, so that each row has ID, Question number, and Numeric value (Question answer).
The original data looks like this:
I found a VBA code that helped me to split rows on this page: Split a row into several, with an identifier
And this is the code I was using:
Sub NewLayout()
For i = 2 To Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
For j = 0 To Cells.Find("*", [A1], , , xlByColumns, xlPrevious).Column
If Cells(i, 13 + j) <> vbNullString Then
intCount = intCount + 1
Cells(i, 1).Copy Destination:=Cells(intCount, 30)
Cells(i, 2 + j).Copy Destination:=Cells(intCount, 31)
Cells(i, 13 + j).Copy Destination:=Cells(intCount, 32)
End If
Next j
Next i
End Sub
The code seems to work, but I have issues with the output: It returns some extra data, and I don't know where is the mistake in the code and how to get rid of it.
The example of the output is attached.
Any help is greatly appreciated!