Imdabaum
08-02-2010, 09:14 AM
I am using the following code to create a new tab. Does anyone have any tips for ensuring that I add the tab at the very end? Currently it forces the tab to be the second to last tab.
Basically it's a menial time sheet, but I'd like to just push a button to start the next week and have the data from the previous tab thrown onto the new tab.
Sub createNewWeek()
'Creates a copy of the tab contents and places it on the next tab.
Dim i As Integer, wb As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'To create a new workbook if nothing open, otherwise create a new sheet
On Error Resume Next
Set wb = ActiveWorkbook
On Error GoTo 0
If wb Is Nothing Then
Workbooks.Add
Else
Dim prevTabname As String
prevTabname = CurrentSheetName()
wb.Sheets.Add.Name = CreateNextTabName(prevTabname)
End If
'Autofit columns for easier readability
Columns.AutoFit
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
Basically it's a menial time sheet, but I'd like to just push a button to start the next week and have the data from the previous tab thrown onto the new tab.
Sub createNewWeek()
'Creates a copy of the tab contents and places it on the next tab.
Dim i As Integer, wb As Workbook
Application.ScreenUpdating = False
Application.DisplayAlerts = False
'To create a new workbook if nothing open, otherwise create a new sheet
On Error Resume Next
Set wb = ActiveWorkbook
On Error GoTo 0
If wb Is Nothing Then
Workbooks.Add
Else
Dim prevTabname As String
prevTabname = CurrentSheetName()
wb.Sheets.Add.Name = CreateNextTabName(prevTabname)
End If
'Autofit columns for easier readability
Columns.AutoFit
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub