Solved

Activesheet instead of sheet1.

Posted on 2007-03-26
10
711 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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

Back Up Your Microsoft Windows Server®

Back up 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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Basic Excel DataEntry for Dashboard analysis 3 25
Excel formula Sumif not working 4 28
VBA Help 18 44
Data Copy 4 22
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

770 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