Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88066

Need code to duplicate worksheet in addition to adding and retitling

$
0
0

I'm trying to set up a spreadsheet that duplicates the previous worksheet into a new tab daily. I have it set up to create a new worksheet and rename it daily, but I can't figure out how to add the worksheet duplication aspect.

I've already written quite a bit of code:

Sub AddDayWkst()
Dim ws As Worksheet
Dim strName As String
Dim bCheck As Boolean

On Error Resume Next
strName = Format(Date, "mm-dd-yy")
bCheck = Len(Sheets(strName).Name) > 0

If bCheck = False Then
    Set ws = Worksheets.Add(Before:=Sheets(1))
    ws.Name = strName
End If

End Sub

All I need is for the program to duplicate the previous day's worksheet and paste it into the new worksheet that is being created.


Viewing all articles
Browse latest Browse all 88066

Trending Articles