|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub test()
- 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
- i0 = 1
- For i = 1 To r
- If Left(.Cells(i, 2), 4) = "仓库AH" Then
- wjm = .Cells(i, 2)
- c = .Rows(i0 & ":" & i).Find(what:="*", searchorder:=xlByColumns, searchdirection:=xlPrevious).Column
- arr = .Range(.Cells(i0, 1), .Cells(i, 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
- i0 = i + 1
- End If
- Next
- End With
- End Sub
复制代码 |
|