'Excel VBA - select a range including a hidden column
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?
Solution 1:[1]
The VBA for that is,
ActiveChart.PlotVisibleOnly = False
See Chart.PlotVisibleOnly Property for more.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
