|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
我也是 初学者 希望可以帮到你!
- Sub dd()
- Dim row1, column1, wb As Workbook, mp$, mf$, ma, mb
- Application.DisplayAlerts = False
- Application.ScreenUpdating = False
- mp = ThisWorkbook.Path & ""
- mf = Dir(mp & "*.cd2")
- x = 0
- While mf <> ""
- If mf <> ThisWorkbook.Name Then
- Set wb = Workbooks.Open(mp & mf)
- x = x + 1
- row1 = Cells(Rows.Count, x).End(xlUp).Row
- column1 = Cells(5, Columns.Count).End(xlToLeft).Column
- ma = Range("b2:b4")
- For a = 1 To column1 - 1
- mb = Range(Cells(5, a + 1), Cells(row1, a + 1))
- ThisWorkbook.Sheets(a).Cells(2, x).Resize(UBound(ma), UBound(ma, 2)) = ma
- ThisWorkbook.Sheets(a).Cells(5, x).Resize(UBound(mb), UBound(mb, 2)) = mb
- Next a
- End If
- wb.Close False
- mf = Dir
-
- Wend
- Set wb = Nothing
- Application.DisplayAlerts = True
- Application.ScreenUpdating = True
- End Sub
-
复制代码
data.zip
(17.8 KB, 下载次数: 6)
|
|