Solved

Activesheet instead of sheet1.

Posted on 2007-03-26
10
706 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
 

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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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 80

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
PaperPort has a feature called the "Send To Bar". It provides a convenient, drag-and-drop interface for using other installed software, such as Microsoft Office. However, this article shows that the latest Office 2016 apps (installed with an Office …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now