|
Option Explicit
Sub test()
Dim ar, i&, Rng As Range, Rng2 As Range, strFileName$, strPath$
Application.DisplayAlerts = False
Application.ScreenUpdating = True
strPath = ThisWorkbook.Path & "\"
With [A1].CurrentRegion
ar = .Value
Set Rng = .Rows(1)
For i = 2 To UBound(ar)
Set Rng2 = .Rows(i)
With Workbooks.Add
strFileName = strPath & ar(i, 1)
With Worksheets(1)
rngCopyToSame Rng, .[A1]
Rng2.Copy .[A2]
.[A1].CurrentRegion.Value = .[A1].CurrentRegion.Value
End With
.SaveAs strFileName: .Close
End With
Next i
End With
Set Rng = Nothing: Set Rng2 = Nothing
Application.DisplayAlerts = False
Application.ScreenUpdating = True
Beep
End Sub
Function rngCopyToSame(ByVal rngSel As Range, ByVal rngTarget As Range)
Dim i&
rngSel.Copy
rngTarget.PasteSpecial xlPasteColumnWidths
rngSel.Copy rngTarget
With rngTarget.Resize(rngSel.Rows.Count, rngSel.Columns.Count)
For i = 1 To .Rows.Count
.Rows(i).RowHeight = rngSel.Rows(i).RowHeight
Next i
End With
End Function
|
评分
-
1
查看全部评分
-
|