How to automatically apply the file path from a cell in VBA?

advertisements

Now I am using this code for running a Excel Chart Template on bar charts:

Apply Saved Chart Template
ActiveChart.ApplyChartTemplate ( _
        "C:\Users\Bosco\AppData\Roaming\Microsoft\Templates\Charts\Bar Chart.crtx" _
        )

Since this link will be decided dynamically, if I save C:\Users\Bosco\AppData\Roaming\Microsoft\Templates\Charts\Bar Chart.crtx into cell A1, how can I auto apply the path of A1 in VBA so that once I change the path in A1, the VBA will automatically follow? thanks!


You can set value of cell A1 to argument, then using this parameter for code

Dim sPath As String
sPath = Cells(1, 1).Value
ActiveChart.ApplyChartTemplate (sPath)