Search code examples
excelvbacopy-paste

Copy data from one worksheet to all other worksheets in same workbook


I have a data in Sheets("Sheet1").Range("AH17:AO25").

I need to copy this data (formula) to all other sheets (Sheet2, Sheet3, Sheet4, ...) to this same range Range.("AH17:AO25") in this workbook.

Public Sub Copy_Data()

Sheets("Sheet1").Select
Range("AH17").Select
ActiveCell.FormulaR1C1 = "=RC[-27]/1000"
Range("AH17").Select
Selection.Copy
Range("AH17:AO25").Select
ActiveSheet.Paste
Application.CutCopyMode = False

Sheets("Sheet1").Range("AH17:AO25").CopyDestination:_
  =wsheet.Ranges("AH17:AO25")

End Sub

Solution

  • Try the next code, please:

    Public Sub Copy_Data_Bis()
      Dim sh As Worksheet, Sh1 As Worksheet
       Set Sh1 = Sheets("Sheet1")
       Sh1.Range("AH17:AO25").Formula = "=RC[-27]/1000"
       For Each sh In ActiveWorkbook.Worksheets
         If sh.Name <> Sh1.Name Then
            sh.Range("AH17:AO25").Formula = Sh1.Range("AH17:AO25").Formula
         End If
       Next
    End Sub
    

    The code does not need any selection, copy - paste and it should be very fast...