Excel 97 VBA Chart Help

Excel 97 VBA Chart Help

Post by Keith Jaslo » Tue, 15 Sep 1998 04:00:00



What VBA command can I use to tell if the user has selected a particular
dataseries in a chart during macro execution.  I have a bar chart with 2
data series, and I want to make a statement like the following:

if activechart.seriescollection(1). (is selected) then
  goperformsomesubroutine
end if

I know how to select the series, but how do I tell if the series is
alread active?

Thanks for any pointers.

--
Regards,


 
 
 

Excel 97 VBA Chart Help

Post by kevi » Thu, 29 Oct 1998 04:00:00


If the series is selected, it can be refered to as the "Selection" object.
Also if you want the name of the series try Selection.Name.  So probably you
are search for something like

With Selection
     ... statements
End With

If there is no selection, I think the selection object returns "Nothing".

Kevin Romero

 
 
 

1. Excel 97, Programing Charts in VBA

I am writing a program which will determine the maximum temperature of
concrete placed in a massive concrete dam.  The concrete is placed in 5
foot lifts (layers) at intervals of from 3 to 5 days between placements.

At the end of the program, I have collected the results into columns at
a particular location on the spreadsheet, i.e., the first column notes
the various time periods over which temperatures were measured (one-half
day increments) and subsequent columns note the maximum temperature at
each time interval for each lift of concrete.  I would like to write a
program to chart and print these results.

I began by recording a macro in a separate workbook.  The problem begins
when I try to use variables in the code which resulted from the recorded
macro.  See the following program:

Sub PrepareCharts()
Dim ColBegin As Integer, ColEnd As Integer, Analyses As Integer,
Dim RowBegin As Integer, RowEnd As Integer
  'Analysis always begins at location C1500
ColBegin = 3
  'Plot four lifts on each chart
ColEnd = ColBegin + 3
RowBegin = 1500
  'Number of rows in analysis = 1500 + Number of time intervals to be
analyzed (K170)
RowEnd = 1500 + (Range("K170").Value -1)
  'The analysis will be done four columns (Lifts) at a time and each set
will be plotted.
  'The total number of Lifts in the analysis is as shown in K167.

For Analyses = 1 To Range("K167") Step 4
Range(Cells(RowBegin, ColBegib), Cells(RowEnd, ColEnd)).Select
  'The above line of code properly selects the required range.
Charts.Add
ActiveChart.ChartType = xlLineMarkers
  'This is where the sub fails.  The next line of code from the recorded
macro is:

ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("E8:H19"),
PlotBy:_
        =xlColumns

If I try to replace Range("E8:H19") from the above with the variable
range

Rangw(Cells(RowBegin, ColBegin), Cells(RowEnd, ColEnd))

I receive the message,

        Run-time error '1004'
        Method 'Cells' of object '_Global' failed

I would appreciate help in resolving this problem if anyone has a
solution.

2. s5 error using encore

3. VBA Excel 97 : Adding a Range Name to Refer to Current Region - Please help

4. RPG/400 and RPG36 YR 2K utility

5. VBA Excel 97 - Adding a Named Range - Please help

6. 3.3-speed Toshiba CD-ROM XM5201B

7. Help: Excel 97 VBA - Using FIND Thru All Sheets

8. Map a drive to a RAS connection

9. Excel VBA question (Excel 97)

10. QUICK : pb for calling DLL functions (from excel 95/VBA) in Excel 97

11. HELP Excel 97 and Word 97 passwords lost - cracker needed

12. HELP WITH VBA & BUBBLE CHARTS IN EXCEL

13. Changing ending column in chart data range - Excel 97 (long)