하나의 통합 문서에서 요약 시트에 인쇄 할 여러 워크 시트의 데이터를 가져 오는 배열이 있습니다. 이 배열은 코드를 단계별로 실행할 때 모든 시트를 통해 정확한 데이터를 가져 오는 것으로 보입니다. 그런 다음 배열은 루프를 통과 할 때마다 정보를 정렬 된 목록에 저장해야합니다.정렬 된 목록이 인쇄되지 않습니다. Excel에서 VBA
원본 데이터는 두 명의 작업자를 나타내는 두 개의 나란히 (수평) 섹션으로 구성됩니다. 형식을 정하는 관점에서 각 근로자의 데이터는 동일합니다.
내 목록이 요약 페이지에 인쇄되지 않고 list.count에 문제가있는 것 같습니다. list.count -1이 있으면 for 루프는 전혀 실행되지 않습니다. -1을 생략하면 루프의 단일 패스가 생깁니다.
목록에 저장된 배열 및/또는 요약 시트에 대한 목록의 출력에 어떤 문제가 있습니까?
Dim arTemp
Dim arTemp1
Dim d As Date
Dim x As Long, Y As Integer
Dim ws As Worksheet
Dim list As Object, list1 As Object
Set list = CreateObject("System.Collections.SortedList")
Set list1 = CreateObject("System.Collections.SortedList")
For Each ws In Worksheets
If ws.Name <> "Summary" And ws.Name <> "SheetX" Then
With ws
For y = 3 to 7
d=DateSerial(Year(.Cells(3,y)), Month(.Cells(3,y)),1
If List.containskey(d) then
arTemp = list(d)
arTemp1 = list1(d)
Else
ReDim arTemp(13)
ReDim arTemp1(13)
End If
arTemp(0) = arTemp(0) + .Cells(4,y)
arTemp(1) = arTemp(1) + .Cells(5,y)
arTemp(2) = arTemp(2) + .Cells(6,y)
.
.
.
arTemp(12) = arTemp(12) + .Cells(16,y)
arTemp(13) = arTemp(13) + 1
list(d) = arTemp
arTemp1(0) = arTemp1(0) + .Cells(4,y + 11)
arTemp1(1) = arTemp1(1) + .Cells(5,y + 11)
arTemp1(2) = arTemp1(2) + .Cells(6,y + 11)
.
.
.
arTemp1(12) = arTemp1(12) + .Cells(16,y + 11)
arTemp1(13) = arTemp1(13) + 1
list1(d) = arTemp1
Next
End With
End If
Next
With Worksheets("Summary")
.Cells.Delete
For x = 0 To list.Count - 1
d = list.getkey(x)
.Cells(x + 43, 1) = Year(d)
.Cells(x + 43, 2) = Month(d)
.Cells(x + 43, 3) = list(d)(0)
.Cells(x + 43, 4) = list(d)(1)
.
.
.
.Cells(x +43, 15) = list(d)(12)
Next
For x = 0 To list.Count - 1
d = list1.getkey(x)
.Cells(x + 43, 1) = Year(d)
.Cells(x + 43, 2) = Month(d)
.Cells(x + 43, 3) = list1(d)(0)
.Cells(x + 43, 4) = list1(d)(1)
.
.
.
.Cells(x +43, 15) = list1(d)(12)
Next
End With