vba query - how do you save a work book with the name of previous working day?

Bradrose84

New Member
Joined
Jan 19, 2015
Messages
1
hi,

Id like to save a work book using a name of indexpricingDDMMYY, but where the date is the previous business/working date. I'd ideally not like to reference a cell in the workbook, just use function like workday-1 or something? I am able to save with the current date-1, but this does not work for holidays...


Sub Macro5()
'
Columns("A:H").Select
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("H7:H28").Select
Application.CutCopyMode = False
Selection.NumberFormat = "m/d/yy;@"
Range("B7:B28").Select
Selection.NumberFormat = "m/d/yy;@"
Range("B2").Select
Selection.NumberFormat = "m/d/yy;@"
ActiveWorkbook.SaveAs Filename:="T:\Brad\Indexpricing" & Format(Date - 1, "DDMMYY") & ".csv", FileFormat:=xlCSV, CreateBackup:= _
False
Range("L16").Select
ActiveWorkbook.Save

End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
ActiveWorkbook.SaveAs Filename:="T:\Brad\Indexpricing" & Format(application.worksheetfunction.Workday(Date,-1), "DDMMYY") & ".csv", FileFormat:=xlCSV,
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top