如何将数据复制到工作簿中的第一张Excel工作表中的多个工作表

如何将数据复制到工作簿中的第一张Excel工作表中的多个工作表

问题描述:

我想从第一个工作表将单元格A103复制到Y148到我Excel工作簿中的每个工作表。我应该使用哪些代码?如何将数据复制到工作簿中的第一张Excel工作表中的多个工作表

+0

您将需要一个'For'循环遍历从工作表2到最后一个工作表的所有工作表,然后在该循​​环内复制范围。 *不是免费的代码写入服务。你需要显示你已有的代码。 –

这是一个四步的方法。 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 
  1. 研究每个动作的代码。例如,谷歌的“VBA Excel循环行”

  2. 令人惊讶的是,你会发现许多随时可以使用的代码,以及你会多快学会做不可能的事情。

  3. 回到这里有任何你自己无法解决的问题。

开始=>

根据“我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