Solved

How to add Date Stamp to Excel spreadsheet name with Macro

Posted on 2016-10-27
4
41 Views
Last Modified: 2016-10-31
Hi Guys, the 3rd Macro on this Excel spreadsheet saves the worksheet with the title "Provider Analysis" and then sends it out via Outlook. How can I add Today's date stamp to the VB code so at the end, the spreadsheet name is "Provider Analysis 28 October 2016"? I send it out every day so the date stamp must change every day too.
ProviderAnalysisHA_PR_NEW.xlsm
0
Comment
Question by:JCutcliffe
  • 2
4 Comments
 
LVL 45

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 41863204
Add something like

& Format(Now(),"dd mmm yyyy")
0
 
LVL 17

Accepted Solution

by:
Roy_Cox earned 250 total points
ID: 41863413
Your code uses saveas in at least three procedures. You might want to change them all.

Sub Macro3()
'
' Macro3 Macro
'

'

    Sheets(Array("Synth", "LiqProv", "LiqProvDetail", "LiqProvUSD", "LiqProvAED", _
                 "LiqProvEUR")).Copy
    ChDir "Y:\Cash & Collateral\LiquidityProvider"
    ActiveWorkbook.SaveAs Filename:= _
                          "Y:\Cash & Collateral\LiquidityProvider\LiqProvider" & Format(Date, "dd mmmm yyyy") & ".xlsx", FileFormat:= _
                          xlOpenXMLWorkbook, CreateBackup:=False
    Application.Dialogs(xlDialogSendMail).Show
End Sub

Open in new window



Also, glancing through the rest of your code you seem to have a lot of redundant code created by the Macro Recorder which should be tidied up, e.g. unnecessary selecting, lines like  ActiveWindow.SmallScroll Down:=6 can all be deleted.
0
 

Author Closing Comment

by:JCutcliffe
ID: 41867576
fab
0
 
LVL 17

Expert Comment

by:Roy_Cox
ID: 41867943
Pleased to help
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now