Hello, I am using the following code to copy/paste a range from one worksheet to multiple sheets. But, my code is only pasting the range onto the sheet that is currently open. Any thoughts on how to get it to copy paste to all sheets that begin with "Labor BOE"?
Here is the line in my code that appears to be not working/ignored:
For Each sh In ActiveWorkbook.Sheets
If Left(sh.Name, 9) = "Labor BOE" Then
Full Code:
Sub CopyPaste_Range()
Dim sh As Worksheet
'Copy Range
Sheets("Template - Tasks").Range("A20:L28").Copy
'Paste to active sheet
For Each sh In ActiveWorkbook.Sheets
If Left(sh.Name, 9) = "Labor BOE" Then
lastRow = ActiveSheet.Cells(Rows.Count, "L").End(xlUp).Row + 1
Range("A" & lastRow).Select
ActiveSheet.Paste
End If
Next sh
Application.DisplayAlerts = True
On Error GoTo 0
End Sub
Here is the line in my code that appears to be not working/ignored:
For Each sh In ActiveWorkbook.Sheets
If Left(sh.Name, 9) = "Labor BOE" Then
Full Code:
Sub CopyPaste_Range()
Dim sh As Worksheet
'Copy Range
Sheets("Template - Tasks").Range("A20:L28").Copy
'Paste to active sheet
For Each sh In ActiveWorkbook.Sheets
If Left(sh.Name, 9) = "Labor BOE" Then
lastRow = ActiveSheet.Cells(Rows.Count, "L").End(xlUp).Row + 1
Range("A" & lastRow).Select
ActiveSheet.Paste
End If
Next sh
Application.DisplayAlerts = True
On Error GoTo 0
End Sub