@ Nadeem, vba로 해결할 수있는 많은 방법 중 하나는 정의 된 유형의 배열에 데이터를로드하는 것입니다. 이 코드를 보면 사용할 수있는 아이디어를 얻을 수 있습니다.
Private Type tPivotValues
sDate As String
sName As String
aHour() As String
End Type
Sub q26832297()
Dim i, j As Long
Dim aPivotValues() As tPivotValues
Dim iArrIndex As Integer
ReDim aPivotValues(0 To 1)
iArrIndex = 0
'reading first date of first element
aPivotValues(iArrIndex).sDate = Sheets(1).Cells(2, 1).Value
aPivotValues(iArrIndex).sName = Sheets(1).Cells(2, 3).Value
j = 0
ReDim aPivotValues(iArrIndex).aHour(0 To 23)
For i = 2 To Sheets(1).Cells(1, 1).End(xlDown).Row
'if date in row different than in array element
If aPivotValues(iArrIndex).sDate <> Sheets(1).Cells(i, 1).Value Then
iArrIndex = iArrIndex + 1
aPivotValues(iArrIndex).sDate = Sheets(1).Cells(i, 1).Value
aPivotValues(iArrIndex).sName = Sheets(1).Cells(i, 3).Value
'setting hours counter to 0
j = 0
ReDim aPivotValues(iArrIndex).aHour(0 To 23)
End If
If aPivotValues(iArrIndex).sDate = Sheets(1).Cells(i, 1).Value Then
aPivotValues(iArrIndex).aHour(j) = Sheets(1).Cells(i, 4).Value
j = j + 1
End If
Next i
'printing data to different sheet
For i = LBound(aPivotValues) To UBound(aPivotValues)
Sheets(2).Cells(i + 1, 1).Value = aPivotValues(i).sDate
Sheets(2).Cells(i + 1, 2).Value = aPivotValues(i).sName
For j = LBound(aPivotValues(i).aHour) To UBound(aPivotValues(i).aHour)
Sheets(2).Cells(i + 1, j + 3).Value = aPivotValues(i).aHour(j)
Next j
Next i
End Sub
덕분에 내가 데이터를 포맷하려고했다 @Tmdean – Nadeem