Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default Sheet Reference Syntax

I'm pretty sure I've done this before, but can't recall the syntax...

I have a variable strDataSheetName that is a string and refers to the name
of a worksheet. I have it as a string variable, because the name of the
sheet I want to refer to has to do with the name of the sheet I am on.

How do I select this sheet using the variable name? See code below (this
syntax does not work)...

ActiveChart.SetSourceData Source:=Sheets("" &
strDataSheetName).Columns("A:F"), PlotBy:=xlColumns

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Sheet Reference Syntax

worksheets(strDatasheetname).Select

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

I'm pretty sure I've done this before, but can't recall the syntax...

I have a variable strDataSheetName that is a string and refers to the name
of a worksheet. I have it as a string variable, because the name of the
sheet I want to refer to has to do with the name of the sheet I am on.

How do I select this sheet using the variable name? See code below (this
syntax does not work)...

ActiveChart.SetSourceData Source:=Sheets("" &
strDataSheetName).Columns("A:F"), PlotBy:=xlColumns

Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default Sheet Reference Syntax

It doesn't like that. I think I misstyped: not selecting, but getting data
from the sheet.

This works:

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns("A:F"),
PlotBy:=xlColumns

But I want to refer to my variable instead of hardcoding the name.

"Tom Ogilvy" wrote:

worksheets(strDatasheetname).Select

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

I'm pretty sure I've done this before, but can't recall the syntax...

I have a variable strDataSheetName that is a string and refers to the name
of a worksheet. I have it as a string variable, because the name of the
sheet I want to refer to has to do with the name of the sheet I am on.

How do I select this sheet using the variable name? See code below (this
syntax does not work)...

ActiveChart.SetSourceData Source:=Sheets("" &
strDataSheetName).Columns("A:F"), PlotBy:=xlColumns

Thanks!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Sheet Reference Syntax

if that works, then
s = "sheet1"
ActiveChart.SetSourceData Source:=Sheets(s).Columns("A:F"),
PlotBy:=xlColumns

should work in the same place as an example.

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

It doesn't like that. I think I misstyped: not selecting, but getting data
from the sheet.

This works:

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns("A:F"),
PlotBy:=xlColumns

But I want to refer to my variable instead of hardcoding the name.

"Tom Ogilvy" wrote:

worksheets(strDatasheetname).Select

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

I'm pretty sure I've done this before, but can't recall the syntax...

I have a variable strDataSheetName that is a string and refers to the name
of a worksheet. I have it as a string variable, because the name of the
sheet I want to refer to has to do with the name of the sheet I am on.

How do I select this sheet using the variable name? See code below (this
syntax does not work)...

ActiveChart.SetSourceData Source:=Sheets("" &
strDataSheetName).Columns("A:F"), PlotBy:=xlColumns

Thanks!

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 385
Default Sheet Reference Syntax

Oh, duh. I had a different problem. Nevermind.

"Tom Ogilvy" wrote:

if that works, then
s = "sheet1"
ActiveChart.SetSourceData Source:=Sheets(s).Columns("A:F"),
PlotBy:=xlColumns

should work in the same place as an example.

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

It doesn't like that. I think I misstyped: not selecting, but getting data
from the sheet.

This works:

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Columns("A:F"),
PlotBy:=xlColumns

But I want to refer to my variable instead of hardcoding the name.

"Tom Ogilvy" wrote:

worksheets(strDatasheetname).Select

--
Regards,
Tom Ogilvy


"Jennifer" wrote:

I'm pretty sure I've done this before, but can't recall the syntax...

I have a variable strDataSheetName that is a string and refers to the name
of a worksheet. I have it as a string variable, because the name of the
sheet I want to refer to has to do with the name of the sheet I am on.

How do I select this sheet using the variable name? See code below (this
syntax does not work)...

ActiveChart.SetSourceData Source:=Sheets("" &
strDataSheetName).Columns("A:F"), PlotBy:=xlColumns

Thanks!

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
cell reference syntax Fred Excel Worksheet Functions 2 December 16th 08 04:01 PM
Worksheet reference syntax? Matt Excel Discussion (Misc queries) 3 May 19th 08 09:02 PM
Reference for VB syntax for Excel functions [email protected] Excel Programming 2 July 14th 06 03:18 AM
Syntax to return the value of a control by reference Broadband Al Excel Discussion (Misc queries) 3 January 26th 06 01:20 AM
Syntax for Range Reference Ken Excel Programming 1 December 8th 04 05:15 PM


All times are GMT +1. The time now is 01:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"