Re: [算表] EXCEL 資料分割--VBA

看板Office作者 (windknife18)時間15年前 (2009/04/07 22:47), 編輯推噓2(202)
留言4則, 4人參與, 最新討論串2/2 (看更多)
剛好有看過類似的,修該一下看合不合用囉,這是 VBA ,如何使用 請參考以前的文章,Excel 2003 確定可以,Excel 2007 要試一下囉 Sub Macro1() Dim rLastCell As Range Dim rCells As Range Dim strName As String Dim lLoop As Long, lCopy As Long Dim wbNew As Workbook With ThisWorkbook.Sheets(1) Set rLastCell = .Cells.Find(What:="*", After:=[A1], _ SearchDirection:=xlPrevious) filesize = 300000 filesize = filesize - 1 For lLoop = 1 To rLastCell.Row Step filesize lCopy = lCopy + 1 Set wbNew = Workbooks.Add .Range(.Cells(lLoop, 1), .Cells(lLoop + filesize, _ .Columns.Count)).EntireRow.Copy _ Destination:=wbNew.Sheets(1).Range("A1") wbNew.Close SaveChanges:=True, Filename:=ThisWorkbook.Path & _ Application.PathSeparator & "Chunk" & lCopy & "Rows" & lLoop & _ "-" & lLoop + filesize Next lLoop End With End Sub -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.229.88.68

04/07 22:55, , 1F
EXCEL VBA不知道要從什麼地方入手?
04/07 22:55, 1F

04/07 22:56, , 2F
推~ 這個真的比較高深不會了 XD
04/07 22:56, 2F

04/08 00:26, , 3F
非常謝謝你!!!
04/08 00:26, 3F

04/08 00:29, , 4F
^^
04/08 00:29, 4F
文章代碼(AID): #19ssU0ko (Office)
文章代碼(AID): #19ssU0ko (Office)