SAMCRO2014
Board Regular
- Joined
- Sep 3, 2015
- Messages
- 160
I am writing coding for a rather large macro and I am trying to decrease the number of characters I use. One way to do this is to define a variable for the long file path name but it is not liking it.
My coding is:
' Ask user for the period of the projection exercise
PNumber = InputBox("What period is it?" & vbNewLine & vbNewLine & "Please enter the number:")
'Define variables
FNTemplate = "J:\FinanceAdmin\Finance\Resource Management\Regional\2019-20\Templates\RPA Zone Roll Up"
FNProjection = "J:\FinanceAdmin\Finance\Resource Management\Regional\2019-20\Projections\P" & PNumber & "\Variances\RPA Roll Up"
'Open all Branch Rollup templates
Workbooks.Open Filename:="'FNTemplate'\2020.PX.LPRA Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.ABSB Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.Appeals Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.CVB Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.DCP Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.ILBI Zone Roll up.v1.RXM.xlsx"
Am I wrong to assume you can define a variable as a file path?
My coding is:
' Ask user for the period of the projection exercise
PNumber = InputBox("What period is it?" & vbNewLine & vbNewLine & "Please enter the number:")
'Define variables
FNTemplate = "J:\FinanceAdmin\Finance\Resource Management\Regional\2019-20\Templates\RPA Zone Roll Up"
FNProjection = "J:\FinanceAdmin\Finance\Resource Management\Regional\2019-20\Projections\P" & PNumber & "\Variances\RPA Roll Up"
'Open all Branch Rollup templates
Workbooks.Open Filename:="'FNTemplate'\2020.PX.LPRA Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.ABSB Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.Appeals Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.CVB Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.DCP Zone Roll up.v1.RXM.xlsx"
Workbooks.Open Filename:="'FNTemplate'\2020.PX.ILBI Zone Roll up.v1.RXM.xlsx"
Am I wrong to assume you can define a variable as a file path?