Forum Discussion
krodgers0000
Nov 04, 2022Copper Contributor
Move specific rows to columns
I'm a novice in excel and would appreciate some help. I have data that comes from Qualtrics and I would like to put it into a better format. Each Assessor (Column A) marks up to 9 students, those det...
HansVogelaar
Nov 04, 2022MVP
This is probably best done using Power Query, but I'll leave that to others. Here is a macro solution:
Sub ConvertData()
Dim wss As Worksheet
Dim wst As Worksheet
Dim s As Long
Dim m As Long
Dim c As Long
Dim n As Long
Dim t As Long
Application.ScreenUpdating = False
Set wss = ActiveSheet
Set wst = Worksheets.Add(After:=wss)
wst.Range("A1:L1").Value = wss.Range("A1:L1").Value
wst.Range("C1").Value = "Student Name"
t = 1
m = wss.Cells(wss.Rows.Count, 1).End(xlUp).Row
For s = 2 To m
n = wss.Cells(s, wss.Columns.Count).End(xlToLeft).Column
For c = 3 To n Step 10
t = t + 1
wst.Cells(t, 1).Resize(1, 2).Value = wss.Cells(s, 1).Resize(1, 2).Value
wst.Cells(t, 3).Resize(1, 10).Value = wss.Cells(s, c).Resize(1, 10).Value
Next c
Next s
Application.ScreenUpdating = True
End Sub