How to copy sheet in workbook to another copy of it?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Chad Dashner
    New Member
    • Jan 2011
    • 3

    How to copy sheet in workbook to another copy of it?

    I am trying to build a vb macro in excel 2007 that will allow me to copy the 4th sheet in my workbook and then create a new sheet from that copy with today's date as the label. I am still learning VB so I am not quite sure how to do this. Help please.
  • Guido Geurs
    Recognized Expert Contributor
    • Oct 2009
    • 767

    #2
    This is the macro for Excel 2003.
    Maybe You have to adapt it to 2007 !

    Code:
    Sub Macro1()
    Dim SHEETidx As Integer
        For SHEETidx = 1 To Sheets.Count
            If Sheets(SHEETidx).Name = CStr(Replace(Date, "/", "-")) Then
                MsgBox "the sheet with this date exist!"
                Exit Sub
            End If
        Next
        Sheets("Sheet4").Select
        Sheets("Sheet4").Copy After:=Sheets(Sheets.Count)
        Sheets(Sheets.Count).Name = CStr(Replace(Date, "/", "-"))
    End Sub

    Comment

    • Chad Dashner
      New Member
      • Jan 2011
      • 3

      #3
      Thank you very much for your help. This was perfect.

      Comment

      Working...