|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test2()
- Dim r%, i%
- Dim arr, brr
- Dim wb As Workbook
- Dim ws As Worksheet
- Dim mypath$, myname$
- Application.ScreenUpdating = False
- Application.DisplayAlerts = False
- Application.SheetsInNewWorkbook = 1
- mypath = ThisWorkbook.Path & ""
- With Worksheets("sheet1")
- r = .Cells(.Rows.Count, 2).End(xlUp).Row
- i1 = r
- For i = r To 1 Step -1
- If Left(.Cells(i, 2), 4) = "仓库AH" Then
- wjm = .Cells(i, 2)
- c = .Rows(i & ":" & i1).Find(what:="*", searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
- arr = .Range(.Cells(i, 1), .Cells(i1, c))
- Set wb = Workbooks.Add
- With wb
- With .Worksheets("sheet1")
- .Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr
- End With
- .SaveAs Filename:=mypath & wjm & ".xls"
- .Close
- End With
- i1 = i - 1
- End If
- Next
- End With
- End Sub
复制代码 |
|