How to copy one worksheet vith command button???

  • Thread starter Thread starter DVAL
  • Start date Start date
D

DVAL

Does anybody know?

Thank you for reading this especially if you are able to help me out on
this.
 
In xl2003 menus:
Edit|move or copy sheet.

Choose copy on the next dialog.

You can see the same option if you rightclick on the worksheet tab.
 
I found it :)

Private Sub CommandButton1_Click()
'---------------------------------------------------------------------------------------
' Module : Sheet3
' DateTime : 08/02/2007 08:08
' Author : Roy Cox (royUK)
' Website : more examples
' Purpose : Add a sheet based on a hidden Main sheet into a specific
position in the workbook
' Disclaimer; This code is offered as is with no guarantees. You may use
it in your
' projects but please leave this header intact.
'---------------------------------------------------------------------------------------
Dim iWsCnt As Integer
iWsCnt = ThisWorkbook.Worksheets.Count
'hide operation from user
Application.ScreenUpdating = False

With ThisWorkbook.Worksheets("Main")
.Visible = xlSheetVisible

'add a sheet as last sheet
.Copy after:=Worksheets(iWsCnt)
'name the new sheet
ActiveSheet.Name = "Stranica" & iWsCnt - 1 'you may need to
change 1 according to the number of sheets not named page
.Visible = xlSheetVeryHidden
End With

Application.ScreenUpdating = True
 
Private Sub CommandButton1_Click()
'---------------------------------------------------------------------------------------
' Module : Sheet3
' DateTime : 08/02/2007 08:08
' Author : Roy Cox (royUK)
' Website : more examples
' Purpose : Add a sheet based on a hidden Main sheet into a specific
position in the workbook
' Disclaimer; This code is offered as is with no guarantees. You may use
it in your
' projects but please leave this header intact.
'---------------------------------------------------------------------------------------
Dim iWsCnt As Integer
iWsCnt = ThisWorkbook.Worksheets.Count
'hide operation from user
Application.ScreenUpdating = False

With ThisWorkbook.Worksheets("Main")
.Visible = xlSheetVisible

'add a sheet as last sheet
.Copy after:=Worksheets(iWsCnt)
'name the new sheet
ActiveSheet.Name = "Stranica" & iWsCnt - 1 'you may need to
change 1 according to the number of sheets not named page
.Visible = xlSheetVeryHidden
End With

Application.ScreenUpdating = True

End Sub
 
Back
Top