Strange Chart behavior when replaying recorded macro. For example from the 4 grid line option only 2 can be activeted through VBA. Why?

Jamualson

Board Regular
Joined
Feb 17, 2021
Messages
143
Office Version
  1. 2019
Platform
  1. Windows
I have strange problems when replaying the macro I recorded. The a) is about the inability to select all 4 type of gridlines at the same type and b) and c) is about showing either an error message or recording a single but irrelevant line. Thank you very much if you have an idea for any of these. Have a nice day :)



a) I wanted to add all 4 type of gridlines to my chart (I can select all 4 to be active at the same time from Excel) but only the last value and category setting remains active (if the last value gridline was major, then it will be major, and if the last category gridline was minor, it will be minor) So I can't make all 4 active from VBA. Why?


ActiveChart.SetElement (msoElementPrimaryValueGridLinesMajor)
ActiveChart.SetElement (msoElementPrimaryCategoryGridLinesMajor)

ActiveChart.SetElement (msoElementPrimaryValueGridLinesMinor)
ActiveChart.SetElement (msoElementPrimaryCategoryGridLinesMinor)

b) There are some SetElement lines which show "Method 'SetElement Of Object Chart' failed".


ActiveChart.SetElement (msoElementLineDropHiLoLine)
ActiveChart.SetElement (msoElementChartWallNone)
ActiveChart.SetElement (msoElementLineSeriesLine)
1614711242534.png

c) And there is a chart element in excel called something like "Positive / negative differences"
but when I record that action, it only records this single line which is completely useless:

ActiveChart.SetElement (msoElementPlotAreaShow)
1614711335878.png
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Jamualson

Board Regular
Joined
Feb 17, 2021
Messages
143
Office Version
  1. 2019
Platform
  1. Windows
All of these has to be set by "ActiveChart.ChartGroups(1).Has..." properties, for example "HasMajorGridlines = True". Strange, but all of these problems are solved by this small change.
 
Solution

Forum statistics

Threads
1,148,108
Messages
5,744,878
Members
423,908
Latest member
Getfour

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top