×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Using TODAY() function to title a worksheet
2

Using TODAY() function to title a worksheet

Using TODAY() function to title a worksheet

(OP)
I am writing a program in VBA where I want the macro to run a daily result to create a new worksheet titled: "today's date" Orders

I know how to use the functions today() and now() within Excel, but I can't figure out the code to make it title the worksheet with the current date.

Can anyone can help?

Thanks

SDFreed

RE: Using TODAY() function to title a worksheet

2
Try the following code, Excel doesnt like / in the worksheet name so the code replaces all the "/" with a "." eg the date 27/10/03 becomes 27.10.03

Sub Macro1()

    sheetname = Date
    namelength = Len(sheetname)
    For t = 1 To namelength
        If Mid$(sheetname, t, 1) = "/" Then
            sheetname = Left$(sheetname, t - 1) & "." & Right$(sheetname, namelength - t)
        End If
    Next
    Sheets.Add
    ActiveSheet.Name = sheetname
    
End Sub

RE: Using TODAY() function to title a worksheet

Try this:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 11/19/2003 by DBP
'

'
    Range("a1").Value = "= TEXT(TODAY(), ""mmm dd yyy"") & "" REPORT"""
    
    Range("A1:J1").Select
    With Selection
        .HorizontalAlignment = xlCenterAcrossSelection
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
End Sub

Cheers,
KE4GFM

RE: Using TODAY() function to title a worksheet

I am using this piece of a code:

Sub report()
sheetname = "Report " & Left((Now), 2) & "-" & Mid((Now), 4, 2) & "-" & Mid((Now), 9, 2)
Sheets.Add
ActiveSheet.Name = sheetname
End Sub
m777182

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources