How can i make these code in 1 button?

Kian

New Member
Joined
Jul 28, 2022
Messages
9
Office Version
  1. 2021
Platform
  1. Windows
Private Sub FINAL_Click ()
Dim xsheet As Worksheet
Set xsheet = ActiveSheet
If xsheet.Name <> "Definitions" And xsheet.Name <> "fx" And xsheet.Name <> "Needs" Then xsheet.Range ("L2: L31" ). Copy
xsheet.Range ("C2: C31"). PasteSpecial Paste: = x IPasteAll, Operation: = xlNone, SkipBlanks:= False, Transpose: = False
End If
Application.ScreenUpdating = True
End sub

Private Sub Commandbutton1_click()
ActiveSheet.copy After:=Worksheets(sheets.count)
On Error Resume Next
ActiveSheet.Name=format(Date, "mmdd")
End Sub
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try this:

VBA Code:
Private Sub FINAL_Click()
  Dim xsheet As Worksheet
  Application.ScreenUpdating = False
  
  Set xsheet = ActiveSheet
  If xsheet.Name <> "Definitions" And xsheet.Name <> "fx" And xsheet.Name <> "Needs" Then
    xsheet.Range("L2:L31").Copy
    xsheet.Range("C2:C31").PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
  
    xsheet.Copy After:=Worksheets(Sheets.Count)
    On Error Resume Next
    ActiveSheet.Name = Format(Date, "mmdd")
  End If
  
  Application.ScreenUpdating = True
End Sub

------------------
Note Code Tag:
In future please use code tags when posting code.
How to Post Your VBA Code it makes your code easier to read and copy and it also maintains VBA formatting.
 
Upvote 0

Forum statistics

Threads
1,215,276
Messages
6,124,006
Members
449,137
Latest member
abdahsankhan

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