Frank Bacchus
Member
I am using the following code to copy and paste the content from a ROW to another ROW, using a command button. This code seems to go thru all sheets in the workbook, which I do not want to do. I want this to operate on a specific sheet.
So, only a specific sheet should be affected by this code. How can I ‘tell’ the code only to do the copy macro on sheet xxxxx? Thanks.
Here is the code:
VBA code: Use Command Button to copy and paste data in Excel
1
2
3
4
5
6
7
8
9
10
11
< use code tags >
So, only a specific sheet should be affected by this code. How can I ‘tell’ the code only to do the copy macro on sheet xxxxx? Thanks.
Here is the code:
VBA code: Use Command Button to copy and paste data in Excel
1
2
3
4
5
6
7
8
9
10
11
Code:
PrivateSubCommandButton1_Click()
Application.ScreenUpdating = False
Dim xSheet As Worksheet
For Each xSheet InThisWorkbook.Worksheets
If xSheet.Name <> "Definitions" And xSheet.Name <> "fx" And xSheet.Name <> "Needs"Then
xSheet.Range("A1:C17 ").Copy
xSheet.Range("J1:L17").PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
EndIf
Next
Application.ScreenUpdating = True
EndSub
< use code tags >