Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I want to tidy up and reduce the amount of code if possible by handling
repetative actions such as adding Series to a chart. Currently I am using something like this below to add a second Series to the ActiveChart but also use almost identical code for Series 3, 4, 5 etc up to a dozen or so. I sthere any way I can reference different Variables within this code e.g. for Pri_Chart_Source_Sheet_2, Pri_Chart_Source_Sheet_3 , Pri_Chart_Source_Sheet_4 etc With ActiveChart If Pri_Series_Data_Column_2 < Empty Then Set PlotValuesSeries = Sheets(Pri_Chart_Source_Sheet_2).Range(Pri_Series_ Data_Column_2 & "2:" & Pri_Series_Data_Column_2 & Last_Row_of_Pri_Source_Sheet_2) Set PlotXValuesSeries = Sheets(Pri_Chart_Source_Sheet_2).Range(Pri_Timesta mp_Data_Column_2 & "2:" & Pri_Timestamp_Data_Column_2 & Last_Row_of_Pri_Source_Sheet_2) Series_Index_No = Series_Index_No + 1 .SeriesCollection.Add Sheets(Pri_Chart_Source_Sheet_2).Range(Pri_Series_ Data_Column_2 & ":" & Pri_Series_Data_Column_2) .SeriesCollection(Series_Index_No).Select With Selection.Border .Weight = xlHairline .LineStyle = xlAutomatic .ColorIndex = 5 End With With Selection .MarkerStyle = xlNone End With With Worksheets(Pri_Chart_Source_Sheet_2) ActiveChart.SeriesCollection(Series_Index_No).XVal ues = PlotXValuesSeries ActiveChart.SeriesCollection(Series_Index_No).Valu es = PlotValuesSeries End With End If End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I reduce repetative code | Excel Discussion (Misc queries) | |||
Formula needed for repetative spreadsheet | Excel Worksheet Functions | |||
Repetative text | Excel Worksheet Functions | |||
Repetative Row Deletes | Excel Discussion (Misc queries) | |||
Repetative conditional formatting | Excel Programming |