ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Define a variable for dynamic chart (https://www.excelbanter.com/excel-programming/354706-define-variable-dynamic-chart.html)

VH

Define a variable for dynamic chart
 
I have a excel file wich I have modified with a number of userforms, macros
and so on. One of the macros make a chart wich the user can page through
several columns. One by one. I want the user to be able to save the file
witout having to change the macro.

I know how to define the open workbook as a variable, but I am not sure how
to use a variable in this macro?

ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='Log_1.xls'!XValues"
ActiveChart.SeriesCollection(1).Values = "='Log_1.xls'!YValues"
ActiveChart.SeriesCollection(1).Name = "='Log_1.xls'!Name"

Can anyone help me?

VH

Define a variable for dynamic chart
 
Maybe I didn't explain well enough. I want to exchange the
"='Log_1.xls'!XValues" with something like "=Variable!XValues". This is to be
able to save the file with another name.

BTW:

VH skrev:

I have a excel file which I have modified with a number of userforms, macros
and so on. One of the macros make a chart which the user can page through
several columns. One by one. I want the user to be able to save the file
witout having to change the macro.

I know how to define the open workbook as a variable, but I am not sure how
to use a variable in this macro?

ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = "='Log_1.xls'!XValues"
ActiveChart.SeriesCollection(1).Values = "='Log_1.xls'!YValues"
ActiveChart.SeriesCollection(1).Name = "='Log_1.xls'!Name"

Can anyone help me?


Udo

Define a variable for dynamic chart
 
Hi,
try "=" & Variable & "!.XValues"

Udo


VH

Define a variable for dynamic chart
 
Thank you Udo! Works perfect!

Udo skrev:

Hi,
try "=" & Variable & "!.XValues"

Udo




All times are GMT +1. The time now is 02:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com