user6486833
user6486833

Reputation: 11

Vba - why xlHistogram does not work?

I need to build a simple histogram chart in Microsoft Excel 2016, but there is something wrong here:

Sheet.addchart2(range, xlHistogram,,,,) 

It works with all the others types but this one. Any help with this would be appreciated.

Upvotes: 1

Views: 1570

Answers (1)

teylyn
teylyn

Reputation: 35915

The new Excel charts introduced in 2016 require a different technique. Microsoft confirms that this is a bug. A workaround is to select a range and then add the chart. Along the lines of:

.Range("A1:B7").Select
ActiveSheet.Shapes.AddChart2(-1, xlHistogram).Select

For more details look at this page in the book "Excel 2016 VBA and Macros"

Upvotes: 4

Related Questions