Copy a range of data to all sheets of the workbook

后端 未结 2 755
终归单人心
终归单人心 2021-01-27 13:47

I have a workbook that contains a database .

On that database there is a certain row of data that i would like to copy and paste to all sheets.

The copying ra

相关标签:
2条回答
  • 2021-01-27 14:26
    Dim Rng As Range, _
        Inp As Range, _
        wS As Worksheet
    
    Set Inp = Selection
    Inp.Interior.ColorIndex = 37
    On Error Resume Next
    Set Rng = Application.InputBox("Copy to", Type:=8)
    On Error GoTo 0
    If TypeName(Rng) <> "Range" Then
        MsgBox "Cancelled", vbInformation
        Exit Sub
    Else
        Rng.Parent.Activate
        Inp.Copy
    
        For Each wS In ActiveWorkbook.Worksheets
            wS.Range("B1").Paste Link:=True
        Next
    End If
    
    Application.CutCopyMode = 0
    
    0 讨论(0)
  • 2021-01-27 14:30

    do you need a Loop for all worksheets ?

        Dim ws as Worksheet
        For Each ws in ActiveWorkbook.Worksheets
            If Not ws.Name = "*Name of the database workbook *" Then    
                Call ws.Range("B1:N1").PasteSpecial(xlPasteAll, xlPasteSpecialOperationNone)
            End If
        Next
    
    0 讨论(0)
提交回复
热议问题