返回列表 上一主題 發帖

[發問] 資料合併問題

回復 1# smallpoper

先將檔案另存為『xlsm』,再將以下程式加入模組中!!
  1. Sub test()
  2.     Sheets("合併後").Cells.Delete Shift:=xlUp
  3.     Sheets("合併後").Range("A1:j1") = Array("No", "X", "Y", "TESTERNO", "BINNO", "VF", "VB", "VB1", "IR", "IR1")
  4.     Sheets("合併前").Select
  5.     Cells(1, 1).Select
  6.     i = 1
  7.     Do
  8.         str1 = Cells(1, i).Value
  9.         last_row = Cells(1, i + 1).End(xlDown).Row
  10.         Sheets(1).Range(Cells(2, i), Cells(last_row, i + 9)).Copy
  11.         Sheets(2).Select
  12.         Sheets(2).[a65535].End(xlUp).Offset(1).PasteSpecial
  13.         ActiveCell.Resize(last_row - 1).Value = str1
  14.         i = i + 11
  15.         Sheets(1).Select
  16.     Loop While Sheets(1).Cells(1, i).Value <> ""
  17.     [a1].Activate
  18.     ThisWorkbook.Save
  19.    
  20.     MsgBox "合併完成!!"
  21. End Sub
複製代碼

TOP

回復 3# GBKEE

感謝 GBKEE 大大的指導,
您寫的程式真的是太深奧了,
光是『SpecialCells(xlCellTypeConstants)』所延伸出來的問題我就研究好久了,
請問有相關的書籍可以參考嗎??

TOP

回復 5# GBKEE

GBKEE 大大,請問您是指Excel的說明嗎??

就『SpecialCells(xlCellTypeConstants)』我就查不到了,
是我在安裝office時就沒有安裝嗎??

TOP

        靜思自在 : 能付出愛心就是福,能消除煩惱就是慧。
返回列表 上一主題