返回列表 上一主題 發帖

[發問] 判斷被選取的儲存格,並取出所在列的相關資料

  1. Private Sub CommandButton1_Click()
  2. Dim ay()
  3. With Sheets("訂單")
  4. r = ActiveCell.Row
  5. a = .Range(.Cells(r, "B"), .Cells(r, "D")).Value
  6. b = .Range(.Cells(r, "U"), .Cells(r, "W")).Value
  7. x = .Cells(r, "S")
  8. y = .Cells(r, "T")
  9. For Each c In .Range(.Cells(r, "G"), .Cells(r, "O")).SpecialCells(xlCellTypeConstants, 1)
  10. k = c.Column
  11. ar = Array(.Cells(3, k), "", c, Val(.Cells(2, k)), c * 20, Val(.Cells(2, k)) * c * 20)
  12. ReDim Preserve ay(s)
  13. ay(s) = ar
  14. s = s + 1
  15. Next
  16. End With
  17. With Sheets("出貨單")
  18. .[B9:G17] = ""
  19. .[C4].Resize(3, 1) = Application.Transpose(a)
  20. .[F4].Resize(3, 1) = Application.Transpose(b)
  21. .[B9].Resize(s, 6) = Application.Transpose(Application.Transpose(ay))
  22. .[G19] = x
  23. .[G21] = y
  24. .Select
  25. End With
  26. End Sub
複製代碼
回復 1# jesscc
學海無涯_不恥下問

TOP

本帖最後由 Hsieh 於 2011-8-27 15:27 編輯

回復 3# jesscc

存檔問題先自己搜尋文章解決
遇到不懂再提出
    rangetest.zip (22.73 KB)
學海無涯_不恥下問

TOP

        靜思自在 : 人生最大的成就是從失敗中站起來。
返回列表 上一主題