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
145
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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
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.
 
Upvote 0
Solution

Forum statistics

Threads
1,223,908
Messages
6,175,305
Members
452,633
Latest member
DougMo

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
Back
Top