save as workday

I use the below to save files which works fine but I need to change it to save as Workday.

sFilename = "JK Daily" 'Set filename
    sPath = "C:\DATA\JKE\LSO \MI\Test\" 'Set Test base path
    If Right(sPath, 1) <> "\" Then sPath = sPath & "\" 'Check for "\"
    sPath = sPath & Format(Date, "yyyy\\mm mmm yyyy\\")
    If Dir(sPath, vbDirectory) = "" Then 'If folder doesn't exist, create it
        Shell "cmd /c mkdir """ & sPath & """"
    End If
    ActiveWorkbook.SaveAs sPath & sFilename & Format(Date - 1, " ddmmyyyy") & ".xls"


I thought it would be a case of changing the last line to :

ActiveWorkbook.SaveAs sPath & sFilename & Format(Application.WorkDay(Date, -1), "DD/MM/YYYY") & ".xls"

But this does not work.

Please assist.

Thanks
JagwarmanAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ProfessorJimJamMicrosoft Excel ExpertCommented:
perhaps something like this

ActiveWorkbook.SaveAs sPath & sFilename & Format(WORKDAY(date,-1) " ddmmyyyy") & ".xls"
JagwarmanAuthor Commented:
Unfortunately that does not work. Expected List Separator so I put comma after (Date, -1) but then I got Sub or function not defined
Saqib Husain, SyedEngineerCommented:
Try removing the slashes from DD/MM/YYYY or replace them with hyphens

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Build an E-Commerce Site with Angular 5

Learn how to build an E-Commerce site with Angular 5, a JavaScript framework used by developers to build web, desktop, and mobile applications.

ProfessorJimJamMicrosoft Excel ExpertCommented:
this one will work for you.  i tested it.

Sub test()


sFilename = "JK Daily" 'Set filename
    sPath = "C:\DATA\JKE\LSO \MI\Test\" 'Set Test base path
    If Right(sPath, 1) <> "\" Then sPath = sPath & "\" 'Check for "\"
    sPath = sPath & Format(Date, "yyyy\\mm mmm yyyy\\")
    If Dir(sPath, vbDirectory) = "" Then 'If folder doesn't exist, create it
        Shell "cmd /c mkdir """ & sPath & """"
    End If
    ActiveWorkbook.SaveAs sPath & sFilename & Format(Application.WorksheetFunction.WorkDay(Date, -1), " ddmmyyyy") & ".xls"



End Sub

Open in new window

JagwarmanAuthor Commented:
Saqib Husain, Syed thanks that works a treat and so simple.
JagwarmanAuthor Commented:
ProfessorJimJam that works as well thanks.
JagwarmanAuthor Commented:
both as good but you have to put one down as the best sorry JimJam
ProfessorJimJamMicrosoft Excel ExpertCommented:
it is fine.  glad it worked for you.

Saqib is a very knowledgeable fellow.  I never cease to learn from others.
JagwarmanAuthor Commented:
I'll second that
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.