返回列表 上一主題 發帖

[發問] 用二維陣列,轉不出來資料

回復 1# jesscc
  1. Sub ContainerDetails()
  2. Set swb = ThisWorkbook
  3.    mypath = "C:\Documents and Settings\Administrator\桌面\"
  4.    myfile = Format(Date, "emmdd") & "已出貨.xlsx"
  5.    swb.Sheets(Array("AA", "BB", "CC")).Copy
  6.    Set wb = ActiveWorkbook
  7.    wb.Sheets("AA").Shapes.Range(Array("CommandButton6")).Delete
  8.    wb.Sheets("AA").Range("B7:J500").ClearContents
  9.    wb.Sheets("BB").Range("B7:J500").ClearContents
  10.    wb.Sheets("CC").Range("B7:J500").ClearContents

  11. For Each Sh In swb.Sheets(Array("AA", "BB", "CC"))
  12. Dim Ay()
  13. With Sh
  14. For i = 7 To .Cells(.Rows.Count, 2).End(xlUp).Row
  15.       If .Range("B" & i) = "v" Or .Range("B" & i) = "*" Then
  16.       ReDim Preserve Ay(s)
  17.       Ay(s) = .Range("B" & i).Resize(, 10).Value
  18.       s = s + 1
  19.       End If
  20. Next
  21. wb.Sheets(.Name).[B7].Resize(s, 10) = Application.Transpose(Application.Transpose(Ay))
  22. Erase Ay
  23. s = 0
  24. End With
  25. Next
  26. wb.SaveAs mypath & myfile
  27. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 3# jesscc


   if s>0 then  wb.Sheets(.Name).[B7].Resize(s, 10) = Application.Transpose(Application.Transpose(Ay))
學海無涯_不恥下問

TOP

        靜思自在 : 能善用時間的人,必能掌握自己努力的方向。
返回列表 上一主題