Solved

Activesheet instead of sheet1.

Posted on 2007-03-26
10
719 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
[X]
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
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

617 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