Naming worksheet
I want to name a worksheet. I want the name to be the current date. If there
already exists a worksheet with that name I want to add time to the name. The problem is that I do not know how to add time to the name of the worksheet. pls help me! any help appreciated! i = Worksheets.Count Worksheets.Add Count:=1, After:=Sheets(i) For j = 1 To i If Sheets(j).Name = Date Then blnTodaySheet = True End If Next If blnTodaySheet = True Then Sheets(i + 1).Name = Date + Time Else Sheets(i + 1).Name = Date & ":" & Time End If |
Naming worksheet
Hi Anne,
Try: '============= Public Sub Tester() Dim i As Long i = Worksheets.Count Worksheets.Add After:=Sheets(i) On Error Resume Next ActiveSheet.Name = Format(Date, "dd-mm-yy") If Err.Number < 0 Then ActiveSheet.Name = Format(Now, "dd-mm-yy hh mm") End If On Error GoTo 0 End Sub '<<============= --- Regards, Norman "Arne Hegefors" wrote in message ... I want to name a worksheet. I want the name to be the current date. If there already exists a worksheet with that name I want to add time to the name. The problem is that I do not know how to add time to the name of the worksheet. pls help me! any help appreciated! i = Worksheets.Count Worksheets.Add Count:=1, After:=Sheets(i) For j = 1 To i If Sheets(j).Name = Date Then blnTodaySheet = True End If Next If blnTodaySheet = True Then Sheets(i + 1).Name = Date + Time Else Sheets(i + 1).Name = Date & ":" & Time End If |
All times are GMT +1. The time now is 10:32 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com