Need to edge out the competition for your dream job? Train for certifications today.
Public Sub CommandButton1_Click()
Dim I As Long, lastrow As Long
Dim t As Long
Dim h As Long
Dim nr As Long
Dim lastcol As Long
Dim firstSelectionRow As Long
Dim firstDataCol As Long
Dim outputLastRow As Long
Dim outputSheet As String
outputSheet = "Sheet2"
lastrow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
lastcol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
For I = 1 To lastrow
If Cells(I, 1) <> "" Then
firstSelectionRow = I + 1
For I = 1 To lastcol
If Cells(1, I) <> "" Then
firstDataCol = I
outputLastRow = 1
For I = firstSelectionRow To lastrow
For h = 1 To firstDataCol - 1
Sheets(outputSheet).Cells(outputLastRow, h).Value = Cells(I, h).Value
For t = firstDataCol To lastcol
If UCase(Cells(I, t).Value) = "X" Then
For nr = 1 To firstSelectionRow - 2
Sheets(outputSheet).Cells(outputLastRow, nr + firstDataCol - 1) = Cells(nr, t).Value
outputLastRow = outputLastRow + 1
Open in new window
This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.