各位高手, 我想利用VBA將不同工作表的料號品名等資料匯總到一個工作頁中, 但是目前應該要38個料件要顯示出來, 但是怎麼弄卻只出現了22個料件, 請協助幫忙找出原因
另外, 下方填入PO/FCST的迴圈,非常耗時, 請問是否有什麼方式以改善迴圈的速度? 陣列是否可以改善? 謝謝
i = 12 '橫向填入料號
For C = 0 To 200
If i > Worksheets.Count Then
'Exit For
Else
A = Application.CountIf(Worksheets(i).Range("i5:z10"), "PO")
b = Application.CountIf(Worksheets(i).Range("i1:z1"), "xxxx")
EA = A - b
For G = 0 To EA
Worksheets("FCST").Range("b1").Offset(, C + G).Value = Worksheets(i).Name
Worksheets("FCST").Range("b1").Offset(1, C + G).Value = Worksheets(i).Range("d1").Offset(0, G * 6) '料號
Worksheets("FCST").Range("b1").Offset(2, C + G).Value = Worksheets(i).Range("c1").Offset(0, G * 6) '尺寸
Worksheets("FCST").Range("b1").Offset(3, C + G).Value = Worksheets(i).Range("c2").Offset(0, G * 6) '廠商
myRow = Worksheets(i).Range("a:a").Find(myToday).Row '直向填入PO/FCST數量
k = 0
For j = 0 To myDay
If k > myDay Then
Exit For
Else
If Worksheets(i).Range("e" & myRow).Offset(k + 1, G * 6).Value <> 0 Then
Worksheets("FCST").Range("a4").Offset(j + 2, C + 1 + G).Value = "* " & Worksheets(i).Range("e" & myRow).Offset(k + 1, G * 6)
Else
Worksheets("FCST").Range("a4").Offset(j + 2, C + 1 + G).Value = Worksheets(i).Range("d" & myRow).Offset(k + 1, G * 6)
End If
k = k + 1
End If
Next j
Next
End If
C = C + EA
i = i + 1
Next C
End If作者: kim223824 時間: 2019-5-19 10:07
Rows("1:1").AutoFilter Field:=7, Criteria1:="XX品項", Operator:=xlFilterValues
Set FR = ActiveSheet.AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible)
For Each xR In FR
If xR.Row > 1 Then Cells(xR.Row, "I") =Application.WorksheetFunction.Subtotal(3, Range("A2:A" & Range("A1048576").End(xlUp).Row))
Next
Set FR = Nothing
Rows("1:1").AutoFilter作者: n7822123 時間: 2019-6-11 03:08