Using a string to make a sheet reference question

cfdh_edmundo

Board Regular
Joined
Nov 9, 2005
Messages
133
Hi,

I'm trying to perform a sheet reference (for an axis on a chart) in VBA but it seems to keep going wrong.

When I hard-code the sheet path in it works, e.g.

Rich (BB code):
ActiveChart.SeriesCollection(1).XValues = "='01.12.09'!R4C1:R45C1"

This picks up the range A4:A45 from the sheet named 01.12.09 and uses it as the x axis values.


However when I try and make this more dynamic, by replacing the 01.12.09 with a string which has the sheet name (dateLookingAt is used to generate the name of the sheet) it seems to have problems:

Rich (BB code):
ActiveChart.SeriesCollection(1).XValues = ""=dateLookingAt&"!R4C1:R45C1"


I think I've messed up the "" and/or ''. Does anyone know how to solve this?

Many thanks,

Chris
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi Chris

Try:

Code:
ActiveChart.SeriesCollection(1).XValues = "='" & dateLookingAt & "'!R4C1:R45C1"
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,425
Members
448,961
Latest member
nzskater

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top