1
我已經編寫了下面的代碼,它根據我的「主」表單列B中的行數有多少行在我的工作簿中創建了一個變量#個附加頁。此宏還複製了各種名稱在主文件的B列中,並將其粘貼到附加頁上的單元格A7中。我遇到問題的最後一步是將以下單元格從主工作表複製到新創建的工作表中:多頁複印數據集
Master:C7,E7,F7,J7,R7,S7,U7,V7,W7,X7 ,Y7,AA7
創建表:A62,D21,D29,D23,D25,D36,I21,I29,I23,I25,I36,D45
任何想法是不勝感激。
Sub CreateAddtlSheets()
Dim ListSh As Worksheet, BaseSh As Worksheet
Dim NewSh As Worksheet
Dim ListOfNames As Range, LRow As Long, Cell As Range
With ThisWorkbook
Set ListSh = .Sheets("Master")
Set BaseSh = .Sheets("Stmt")
End With
LRow = ListSh.Cells(Rows.Count, "B").End(xlUp).Row
Set ListOfNames = ListSh.Range("B7:B" & LRow)
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
End With
For Each Cell In ListOfNames
BaseSh.Copy After:=Sheets(Sheets.Count)
Set NewSh = ActiveSheet
With NewSh
On Error GoTo 0
.Range("A7") = Cell.Value
.Calculate
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
End With
Next Cell
With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
BaseSh.Activate '--Select Base.
Sheets("Setup").Select
End Sub
如果我在'with newSh'內執行'.range(「A62」)= ListSh.range(「C7」)'等等。 – findwindow