Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Activesheet instead of sheet1.

Posted on 2007-03-26
10
714 Views
Last Modified: 2008-02-01
Hello group,

Instead of :

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range(strSelectedRange), PlotBy:=xl3DColumn

I like to use:

ActiveChart.SetSourceData Source:=ACTIVESHEET.Range(strSelectedRange), PlotBy:=xl3DColumn

but it the VB compiler complains that this doesn't support the method !!!

How can I solve this limitation? maybe I'm using a WorkBook that doesn't have sheet1 or it is renamed. Then what?!

Regards,
ak
0
Comment
Question by:akohan
10 Comments
 
LVL 18

Expert Comment

by:p912s
ID: 18796909
What if you use this:
  ActiveWorkbook.ActiveSheet

Instead of this:
  ActiveSheet
0
 
LVL 18

Expert Comment

by:p912s
ID: 18796927
Or maybe:
  Selection.Address

Instead of:
  ACTIVESHEET.Range(strSelectedRange)
0
 
LVL 18

Expert Comment

by:p912s
ID: 18796931
>>strSelectedRange
Where does this come from?

If the above didn't help; can you post the rest of the code?
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 

Author Comment

by:akohan
ID: 18796958


Hi,

Thanks but neither one works. It complains that "Object Doesn't support this property or method".

regards,
ak


0
 
LVL 18

Expert Comment

by:p912s
ID: 18797181
>> It complains that "Object Doesn't support this property or method".
Which is the same as your original error. Both are valid statements depending on how they're used.

Can you post your spreadsheet? You can upload here in a zipped format - http://ee-stuff.com/

Please post the link that is provided after the upload.
0
 
LVL 81

Expert Comment

by:byundt
ID: 18797650
Is this a chart embedded on a worksheet (in which case your code should work) or a separate chartsheet? If the latter, then the activesheet is a chartsheet, which has no range property.

I tested the following code with an embedded chart on a worksheet. I selected the chart, then ran the sub:

Sub ChangeChart()
Dim strSelectedRange As String
strSelectedRange = "H8:I9"
ActiveChart.SetSourceData Source:=ActiveSheet.Range(strSelectedRange), PlotBy:=xl3DColumn
End Sub
0
 
LVL 2

Expert Comment

by:JasonRubens
ID: 18798818
What about

Dim mySheet as Worksheet
Set mySheet = activesheet

and then
ActiveChart.SetSourceData Source:=mySheet.Range(strSelectedRange), PlotBy:=xl3DColumn
0
 

Accepted Solution

by:
akohan earned 0 total points
ID: 18804719


Thanks all. Still doesn't work for me. Anyway I changed my approch. At least this works now:

    With ActiveSheet.ChartObjects.Add(Left:=100 + g_iLeftMargin, Width:=375, Top:=75 + g_iTopMargin, Height:=225)
   
        .Chart.ChartType = ar_ChartFormat(CInt(tvCtrlChartType.SelectedItem.Index - 3))
        .Chart.SetSourceData Source:=ActiveSheet.Range(strSelectedRange)
        .Chart.SeriesCollection(1).XValues = strXValues
       
    End With

Once again thanks for your time and help.

regards,
ak
0
 

Author Comment

by:akohan
ID: 18805464


Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question