如何将数据复制到工作簿中的第一张Excel工作表中的多个工作表
答
这是一个四步的方法。 1.设计以纯的话,像动作,
' loop through rows 103 to 148 in Sheet1
' copy the row
' loop through all other sheets in the workbook
' paste the row in the first empty row at the bottom of each
研究每个动作的代码。例如,谷歌的“VBA Excel循环行”
令人惊讶的是,你会发现许多随时可以使用的代码,以及你会多快学会做不可能的事情。
回到这里有任何你自己无法解决的问题。
答
根据“我excel工作簿中的每张纸”的含义,这可能比通过所有其余工作表循环粘贴操作要快。
Sub galumph()
Dim w As Long, wss As String, wsa as Variant
For w = 2 To Worksheets.Count
wss = wss & IIf(CBool(Len(wss)), ";", vbNullString) & Worksheets(w).Name
Next w
wsa = Split(wss, ";") 'make array of worksheet names
Worksheets(1).Range("A103:Y148").Copy 'copy from A103:Y148 on Sheet1
Worksheets(wsa).Select 'select all of the remaining worksheets
Worksheets(wsa(0)).Range("A1").Activate 'activate the destination on one of the worksheets
Worksheets(wsa(0)).Paste 'paste the data into all worksheets
End Sub
您将需要一个'For'循环遍历从工作表2到最后一个工作表的所有工作表,然后在该循环内复制范围。 StackOverflow不是免费的代码写入服务。你需要显示你已有的代码。 –