|
-
Aug 7th, 2014, 08:14 AM
#1
Thread Starter
New Member
[RESOLVED] "You must select a shape"
Hey all -- I've been having some trouble with some VBCode, below.
Code:
Dim shtData As Worksheet
Application.ScreenUpdating = False
' oExcel.Sheets(Layer).Activate **The variable Layer is the
current Excel sheet being generated**
Set shtData = Layer
shtData.Activate
Set shtData = ActiveSheet
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=shtData.Range("M23")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).XValues = _
Worksheets("Layer " & i).Range("A13:A58")
ActiveChart.SeriesCollection(1).Values = _
Worksheets("Layer " & i).Range("A13:A58")
ActiveChart.SeriesCollection(2).XValues = _
Worksheets("Layer " & i).Range("B13:B58")
ActiveChart.SeriesCollection(2).Values = _
Worksheets("Layer " & i).Range("B13:B58")
ActiveChart.Location Where:=xlLocationAsObject, Name:=Layer
What this code does is iteratively go through an excel list of variable size, and adds an embedded chart to each of them. This is during a setup phase where the larger code generates a whole excel doc.
It has been functioning in three different ways, depending on how I play with the code (comment out lines, etc). 1. It goes through and generates the Excel document properly, but without charts. 2. It goes through and generates the Excel document properly, but the charts are in their own sheets (not embedded). 3. It goes through and generates the Excel document properly, with charts, but during setup, I get the error "You must select a shape" for each sheet in the Excel document. The number of sheets can be over 125, so it's an issue.
I wonder if any of you have any insight? If you need more detail, I'm happy to provide.
Last edited by strunkus; Aug 7th, 2014 at 02:13 PM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|