|
▼びめびめ さん:
1〜5行目、+6行目 から 100行分 を → datas_001.xlsという名前で保存
1〜5行目、+106行目から 100行分 を → datas_002.xlsという名前で保存
1〜5行目、+206行目から 100行分 を → datas_001.xlsという名前で保存
・・・
ということですか?
Sub Try1()
Dim WS1 As Worksheet
Dim LastRow As Long
Dim wb As Workbook
Dim wbPath As String
Dim i As Long, n As Long
With Workbooks("datas.xls")
wbPath = .Path & "\"
Set WS1 = .Worksheets(1)
End With
LastRow = WS1.Cells(WS1.Rows.Count, 1).End(xlUp).Row
For i = 6 To LastRow Step 100 '◆100行Step で
n = n + 1
Set wb = Workbooks.Add(xlWBATWorksheet)
With wb.Worksheets(1)
WS1.Rows("1:5").Copy .Cells(1)
WS1.Rows(i).Resize(100).Copy .Cells(6, 1) '◆100行づつ
End With
wb.SaveAs wbPath & "datas_" & Format$(n, "000") & ".xls"
wb.Saved = True
wb.Close
Set wb = Nothing
Next
End Sub
|
|