Copy paste cells to same location in every worksheet

Dokat

Active Member
Joined
Jan 19, 2015
Messages
304
Office Version
  1. 365
Hi,

I have below code where i'd like to copy AG21, W22 and AB22 from Sheets("ST") and paste to same cell location in every worksheet excluding "Summary" an "ST". Can anyone help me modify the code as it is not working currently


VBA Code:
Option Explicit

Sub TEST()
Dim sht As Worksheet
Sheets ("ST").Range("AG21").Copy
Sheets ("ST").Range("W22").Copy
Sheets ("ST").Range("AB22").Copy
Selection.Range("AG21").PasteSpecial xlPasteValues
Selection.Range("W22").PasteSpecial xlPasteValues
Selection.Range("AB22").PasteSpecial xlPasteValues
Application.CutCopyMode = False


End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Try This:
VBA Code:
Option Explicit

Sub TEST()
'Modified  2/17/2022  1:53:43 AM  EST
Application.ScreenUpdating = False
Dim i As Long

    For i = 1 To Sheets.Count
        Select Case Sheets(i).Name
            Case "ST", "Summary"
        
            Case Else
                Sheets(i).Range("AG21").Value = Sheets("ST").Range("AG21")
                Sheets(i).Range("W22").Value = Sheets("ST").Range("W22")
                Sheets(i).Range("AB22").Value = Sheets("ST").Range("AB22")
        End Select
    Next
Application.ScreenUpdating = True

End Sub
 
Upvote 0
Solution
Try This:
VBA Code:
Option Explicit

Sub TEST()
'Modified  2/17/2022  1:53:43 AM  EST
Application.ScreenUpdating = False
Dim i As Long

    For i = 1 To Sheets.Count
        Select Case Sheets(i).Name
            Case "ST", "Summary"
       
            Case Else
                Sheets(i).Range("AG21").Value = Sheets("ST").Range("AG21")
                Sheets(i).Range("W22").Value = Sheets("ST").Range("W22")
                Sheets(i).Range("AB22").Value = Sheets("ST").Range("AB22")
        End Select
    Next
Application.ScreenUpdating = True

End Sub
Works perfect. Thank you
 
Upvote 0

Forum statistics

Threads
1,215,497
Messages
6,125,160
Members
449,209
Latest member
BakerSteve

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top