Solved

Activesheet instead of sheet1.

Posted on 2007-03-26
10
708 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Compile Error 7 39
Some AHK commands fail in Microsoft OneNote 5 28
Excel 2016 formulas 5 22
Pivot help - Display only Is Not Null 7 12
Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
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 a scrolling table in Microsoft Excel using the INDEX function.

932 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

15 Experts available now in Live!

Get 1:1 Help Now