Naming worksheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
'<<=============
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top