상위 데이터 세트가있는 시트의 버튼에 다음 매크로를 지정하십시오. 버튼을 클릭하면 (매크로가 지정되면) 하단 행으로 변환됩니다. 모든 문제는 답변하십시오.
Sub SortData()
' Assign the following macro to a button or shape to achieve your result
Dim StartingSheet, val As String
StartingSheet = ActiveSheet.Name
With Sheets.Add
For i = 1 To Sheets(StartingSheet).Cells(Rows.Count, 1).End(xlUp).Row
For j = 1 To 3
.Cells(((i - 1) * 3 + (j Mod 3) + 1), 1).Value = Sheets(StartingSheet).Cells(i, 1).Value
.Cells(((i - 1) * 3 + (j Mod 3) + 1), 2).Value = Sheets(StartingSheet).Cells(i, 2).Value
.Cells(((i - 1) * 3 + (j Mod 3) + 1), 3).Value = Sheets(StartingSheet).Cells(i, 3).Value
If j = 1 Then
val = "$ volume"
.Cells(((i - 1) * 3 + (j Mod 3) + 1), 5).Value = Replace(Sheets(StartingSheet).Cells(i, 5).Value, "$", "")
End If
If j = 2 Then
val = "cost"
.Cells(((i - 1) * 3 + (j Mod 3) + 1), 5).Value = Replace(Replace(Sheets(StartingSheet).Cells(i, 6).Value, "$", ""), " cost", "")
End If
If j = 3 Then
val = "units"
.Cells(((i - 1) * 3 + (j Mod 3) + 1), 5).Value = Replace(Sheets(StartingSheet).Cells(i, 4).Value, " units", "")
End If
.Cells(((i - 1) * 3 + (j Mod 3) + 1), 4).Value = val
Next
Next
End With
End Sub