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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,224,746
Messages
6,180,705
Members
452,994
Latest member
Janick

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