ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Charts and Charting in Excel (https://www.excelbanter.com/charts-charting-excel/)
-   -   change point size of all points in an xy chart (https://www.excelbanter.com/charts-charting-excel/118128-change-point-size-all-points-xy-chart.html)

kilter

change point size of all points in an xy chart
 
I have 255 series in an xy chart and would like to reduce the point
size to 2. Could some kind soul give me a hand with a vba script to do
this (I have not programmed in vba before). Any help very gratefully
received.


ExcelBanter AI

Answer: change point size of all points in an xy chart
 
Sure, I can help you with that! Here's a step-by-step guide on how to change the point size of all points in an XY chart using VBA:
  1. Open your Excel workbook and press Alt + F11 to open the Visual Basic Editor.
  2. In the Project Explorer window, find the worksheet that contains the XY chart you want to modify and double-click on it to open the code window.
  3. Click on the "Insert" menu and select "Module" to create a new module.
  4. In the new module, paste the following code:

    Formula:

    Sub ChangePointSize()
        
    Dim cht As ChartObject
        Dim ser 
    As Series
        
        
    For Each cht In ActiveSheet.ChartObjects
            
    For Each ser In cht.Chart.SeriesCollection
                ser
    .MarkerSize 2
            Next ser
        Next cht
    End Sub 

  5. Press F5 or click on the "Run" button to execute the code.
  6. The code will loop through all the chart objects in the active worksheet and change the marker size of all series to 2.

That's it! The point size of all points in your XY chart should now be reduced to 2. If you want to change the point size to a different value, simply modify the number in the "ser.MarkerSize = " line of the code.

Andy Pope

change point size of all points in an xy chart
 
Hi,

This should do it. Just select the chart before running.

Paste into a standard code module.

Sub ReducePointSize()

Dim serX As Series

For Each serX In ActiveChart.SeriesCollection
If serX.MarkerSize - 2 1 Then
serX.MarkerSize = serX.MarkerSize - 2
End If
Next

End Sub

Cheers
Andy

kilter wrote:
I have 255 series in an xy chart and would like to reduce the point
size to 2. Could some kind soul give me a hand with a vba script to do
this (I have not programmed in vba before). Any help very gratefully
received.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info

Jon Peltier

change point size of all points in an xy chart
 
Marker size?

Select the chart and run this macro. You'll probably change your mind about
the size of 2, so it asks what size you want when it runs, with a default of
2. It also makes sure you've selected a chart first.

Sub ChangeMarkerSize()
Dim srs As Series
Dim newsize As Long
If ActiveChart Is Nothing Then
MsgBox "Select a chart and try again."
Else
newsize = Application.InputBox("What size for your markers?", _
"Enter Marker Size", 2, , , , , 1)
If newsize < 2 Then newsize = 2
If newsize 72 Then newsize = 72
For Each srs In ActiveChart.SeriesCollection
On Error Resume Next
srs.MarkerSize = newsize
On Error GoTo 0
Next
End If
End Sub

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"kilter" wrote in message
oups.com...
I have 255 series in an xy chart and would like to reduce the point
size to 2. Could some kind soul give me a hand with a vba script to do
this (I have not programmed in vba before). Any help very gratefully
received.




kilter

change point size of all points in an xy chart
 
Thanks folks,

fantastic help!



All times are GMT +1. The time now is 10:32 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com