Monday, 26 September 2016

How Can I Fix - Delete Chart Series with toggle button?

Delete Chart Series with toggle button

Hello,
I have the following code, each sub is called by a toggle button (3 in total) on on a sheet.
I would like to toggle the series on and off by pressing each toggle button .
So for the first sub, SingleChart, pressing the toggle button tglSingle  puts  3 series in 3 different charts (Life,Year,Month).
Pressing the toggle again would delete the 3 series.
How can I do that?
Also, is there a way to write a more elegant code as a lot of lines are repeated throughout?
Thanks



Sub SingleChart()
    If sheetTotal.tglSingle = True Then
        With Worksheets("Charts").ChartObjects("Life Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Single_Rides_Life_Chart"
            .XValues = Array(2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020)
            .Name = "=""Single rides"""
            .HasDataLabels = True
        End With
        With Worksheets("Charts").ChartObjects("Year Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Single_Rides_Year_Chart"
            .XValues = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
            .Name = "=""Single Rides"""
            .HasDataLabels = True
        End With
        With Worksheets("Charts").ChartObjects("Month Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Single_Rides_Month_Chart"
            .XValues = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31)
            .Name = "=""Single Rides"""
            .HasDataLabels = True
        End With
    End If
End Sub
Sub TrackChart()
    If sheetTotal.tglTrack = True Then
        With Worksheets("Charts").ChartObjects("Life Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Track_Rides_Life_Chart"
            .XValues = Array(2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020)
            .Name = "=""Track Rides"""
            .HasDataLabels = True
        End With
        With Worksheets("Charts").ChartObjects("Year Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Track_Rides_Year_Chart"
            .XValues = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
            .Name = "=""Track Rides"""
            .HasDataLabels = True
        End With
        With Worksheets("Charts").ChartObjects("Month Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Track_Rides_Month_Chart"
            .XValues = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31)
            .Name = "=""Track Rides"""
            .HasDataLabels = True
        End With
    End If
End Sub
Sub RacesChart()
    If sheetTotal.tglRaces = True Then
        With Worksheets("Charts").ChartObjects("Life Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Races_Rides_Life_Chart"
            .XValues = Array(2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020)
            .Name = "=""Races"""
            .HasDataLabels = True
        End With
        With Worksheets("Charts").ChartObjects("Year Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Races_Rides_Year_Chart"
            .XValues = Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
            .Name = "=""Races"""
            .HasDataLabels = True
        End With
        With Worksheets("Charts").ChartObjects("Month Chart").Chart.SeriesCollection.NewSeries
            .Values = "=SST.xlsm!Races_Rides_Month_Chart"
            .XValues = Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31)
            .Name = "=""Races"""
            .HasDataLabels = True
        End With
    End If
End Sub

Anwsers to the Problem Delete Chart Series with toggle button

Download Error Fixer for Free Now

I suppose one method you could try would be to put a marker value in a hidden column to store whether the toggle is in the 'on' or 'off' position, you could then check for the value in that cell and add or delete the series depending on its value, updating
the value in the hidden cell to denote the new situation.

  1. Access the files on your computer via MY COMPUTER
  2. Under the C: drive, access the WINDOWS folder
  3. Select the SOFTWARE DISTRIBUTION folder, followed by the DOWNLOAD folder.
  4. Delete any files within this download folder.
  5. If you are unable to delete these files, open the command prompt (CMD) as the administrator, and type "net stop wuauserv" into the CMD prompt window. Press ENTER. This should allow you to delete the files from step 4.
  6. Once the files are deleted, open and run the CMD as the administrator and type "wuauclt.exe /updatenow". Press ENTER.

Recommended Method to Repair the Problem: Delete Chart Series with toggle button:

How to Fix Delete Chart Series with toggle button with SmartPCFixer?

1. Click the button to download SmartPCFixer . Install it on your computer.  Run it, and it will scan your computer. The junk files will be shown in the scan result.

2. After the scan is finished, you can see the errors and problems need to be repaired. Click Fix All.

3. When the Fixing part is done, your computer has been speeded up and the errors have been fixed


Related: How to Update & Download NVidia GeForce 6100/nForce 420 WHQL Certified driver v.178.13,How to Update & Download NVidia GeForce 7600 GS Video Driver v.295.75 Certified,How Can I Update & Download NVidia GeForce 820M Driver v.344.48 WHQL,[Solved] Download NVidia GeForce GTX 560M VGA Driver v.296.17 Certified,Way to Update & Herunterladen NVidia GeForce GT 130M Video Treiber v.295.75 Certified,How to Update & Download SONY SVE14A1X1RH Realtek Ethernet Driver,Where to Download SONY SVS13A2W9ES Bluetooth Driver (Intel) v.2.6 - 2.6.23.40059,Best Way to Update & Download SONY VGN-CR203E Conexant HDAUDIO SoftV92 Data Fax Modem with SmartCP Setup Program v.7.62.0.50 driver,Best Way to Download SONY VGN-FE790G/N Wireless LAN Driver v.10.6.0.29,Method to Update & Download SONY VGN-NR31Z/S Firmware Extension Parser Device v.8.0.2.3,How to Fix Error 0x0000c1f5 SoluciĆ³n?,Error 0x80071a91 Win7 Fix Patch,Error 0x800ccc60 Windows Live Mail [Solved],Error Message 0x800ccc79 Outlook 2000 Fix,What is Error 0xc1ab0001?,[Answered] x64 saplugin dll,How to Fix Problem - Kb943729 Download?,Troubleshooting: Bccode D1 Error,Java Runtime Tech Support,Troubleshooting: ERROR NO SUCH GROUP Error
Read More: How to Fix - Dell Windows 7 Factory Restore?,How Can I Fix - Delete IE8 entirely?,Troubleshoot:Dell Photo Printer 720 Driver needed for Windows 7 Ultimate 32bit. Error,Troubleshoot:data formatting in Excel 2007 Error,Tech Support: Dell E6410 and Windows 8.1 - black sreen after sleeping mode

No comments:

Post a Comment