thanks in advance to anyone willing to help.
I have put together this code to select non continuous cells of a table to create a graph (the number of rows of the table varies)
Sub graphB() Dim sht As Worksheet Dim LastRow As Long Set sht = ThisWorkbook.Worksheets("CF_total") LastRow = sht.Range("E2").CurrentRegion.Rows.Count ActiveSheet.Shapes.AddChart.Select Set myRange = Union(Range(sht.Cells(2, 5), sht.Cells(LastRow, 5)), Range(sht.Cells(2, 12), sht.Cells(LastRow, 12))) ActiveChart.SetSourceData Source:=myRange ActiveChart.ChartType = xlPie End Sub
But now I have decided to hide column number 12 of the worksheet(which contains the data that I want to plot) and it does not work anymore. Any ideas on how I could solve this?
The VBA for that is,
ActiveChart.PlotVisibleOnly = False
See Chart.PlotVisibleOnly Property for more.