Choose current month dynamically

How do I translate the macro of a filepath from

prevdate = Format(DateAdd(“M”, 0, Now), “Mmm”)
prevdate_year = Format(DateAdd(“Y”, 0, Now), “YYYY”)
MonthNum = Month(Date)
Source_Folder = “V:\Finance\Systems-Risk-ERM\OrderToCash\C2C\ACRA Biz Profile” & prevdate_year & “” & MonthNum & ". " & prevdate

to "V:\Finance\Systems-Risk-ERM\OrderToCash\C2C\ACRA Biz Profile" + DateAdd.now.ToString(“YYYY”) + Month(Date) + ". " + now.ToString(“Mmm”)

The end result should look like this:
V:\Finance\Systems-Risk-ERM\OrderToCash\C2C\ACRA Biz Profile\2022\10. Oct

I took some reference from this thread below, but am still seeing an error in the dialog
How to Choose the current month folder

Thanks for the help in advance!

Hi @Justine

How about this expression?

Year = Now.Year.Tostring 

Monthnum =DateTime.Now.ToString("MM")

MonthMMM = DateTime.Now.ToString("MMM")

“V:\Finance\Systems-Risk-ERM\OrderToCash\C2C\ACRA Biz Profile\"+Year+"\"+Monthnum+". "+MonthMMM

image

Regards
Gokul

1 Like

Hi @Gokul001 , if i would like a month prior, it will be as follows?

“V:\Finance\Systems-Risk-ERM\OrderToCash\C2C\ACRA Biz Profile"+Year+“"+Monthnum-1+”. "+MonthMMM-1

Hi @Justine

You don’t need to change in this expression

Year = Now.Year.Tostring 

Monthnum =DateTime.Now..AddMonths(-1)ToString("MM")

MonthMMM = DateTime.Now..AddMonths(-1)ToString("MMM")

“V:\Finance\Systems-Risk-ERM\OrderToCash\C2C\ACRA Biz Profile\"+Year+"\"+Monthnum+". "+MonthMMM

Check out the Monthnum & MonthMMM expression above

Regards
Gokul

1 Like

Hello @Justine ,

What about this topic?

Perhaps would help you solve the issue in a easier way.

Best regards,
Marius

1 Like

@Gokul001 , thank you so much for the help!

1 Like

@Marius_Puscasu , thank you! Will take a look.

Hi @Justine

Check out the Tutorial

Regards
Gokul

1 Like

@Gokul001 , useful references, thanks for providing the thread!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.