T
The poster formerly known as Colleyville Alan
I showed my boss a simple graph with 6 checkboxes that allowed a user to
show or to hide data. He liked this alot and asked if I could build
something with many checkboxes. I said sure and after we surveyed my
colleagues, we came up with 70 different data series. My challenge now is
to manage how the checkboxes interact with the data and the graph.
(note: I am a finance guy and not a programmer, though I can write some
VBA).
I have a tab with the data series called "Data". Another tab has formulas
and is called Formulas. This tab references the data series on the Data
tab. For example:
IF(ISBLANK(Data!B7),NA(),IF(Main!$S$2,Data!B7,NA()))
This allows the graph to show blanks where data is missing as some series
have longer history than others.
I had toyed with the idea of adding/deleting series from the graph depending
upon the state of the checkbox. But I came up with an idea that seems more
manageable.
There is now a 3rd tab called Lookup that has seven series using a Hlookup
table to pull info from the Formulas tab. It looks at the name of the data
series and pulls that info to this tab. The graph then has seven series
that reference these cells. All I have to do is blank out the name of the
data series at the top of the column and all elements become #NA.
One of the reasons that I went to this approach is that while unchecking a
box that was linked to a series caused the series to disappear from the
graph, the legend still had the symbol for it. If I had 70 series and only
2 boxes were checked, then I would show 2 series on the graph but have all
70 series in the legend, 2 with names and 68 without.
My idea is to read the status of all checkboxes into an array. The
Checkbox_Click event calls a sub that counts the number of boxes checked.
If there are already 7 checkboxes selected and the user attempts to check an
8th, the code would not allow that and would notify the user. (not that
anyone would be that silly, such a graph would be unreadable). If there are
less than 7 boxes checked, the code would grab the name of the checked boxes
from the array and write them to the Lookup tab in the column headings used
by the Hlookup function.
My question then becomes: is this a reasonable approach or is there a more
efficient way to do this? I thought about creating a fixed array of 7
elements scanning the controls and getting the first 7 and using them. If
the array was full and the user attempted to add an 8th checkbox, again it
would prevent that from happening. So since this array would never go over
7 elements, would I really need to keep the status of all 70 checkboxes in
an array of size 70?
Perhaps I should use a Dynamic Array and check the size with Ubound?
Any other ideas for managing this many checkboxes? I'm sure that I am not
the first guy to do this.
Thanks in advance.
Alan
show or to hide data. He liked this alot and asked if I could build
something with many checkboxes. I said sure and after we surveyed my
colleagues, we came up with 70 different data series. My challenge now is
to manage how the checkboxes interact with the data and the graph.
(note: I am a finance guy and not a programmer, though I can write some
VBA).
I have a tab with the data series called "Data". Another tab has formulas
and is called Formulas. This tab references the data series on the Data
tab. For example:
IF(ISBLANK(Data!B7),NA(),IF(Main!$S$2,Data!B7,NA()))
This allows the graph to show blanks where data is missing as some series
have longer history than others.
I had toyed with the idea of adding/deleting series from the graph depending
upon the state of the checkbox. But I came up with an idea that seems more
manageable.
There is now a 3rd tab called Lookup that has seven series using a Hlookup
table to pull info from the Formulas tab. It looks at the name of the data
series and pulls that info to this tab. The graph then has seven series
that reference these cells. All I have to do is blank out the name of the
data series at the top of the column and all elements become #NA.
One of the reasons that I went to this approach is that while unchecking a
box that was linked to a series caused the series to disappear from the
graph, the legend still had the symbol for it. If I had 70 series and only
2 boxes were checked, then I would show 2 series on the graph but have all
70 series in the legend, 2 with names and 68 without.
My idea is to read the status of all checkboxes into an array. The
Checkbox_Click event calls a sub that counts the number of boxes checked.
If there are already 7 checkboxes selected and the user attempts to check an
8th, the code would not allow that and would notify the user. (not that
anyone would be that silly, such a graph would be unreadable). If there are
less than 7 boxes checked, the code would grab the name of the checked boxes
from the array and write them to the Lookup tab in the column headings used
by the Hlookup function.
My question then becomes: is this a reasonable approach or is there a more
efficient way to do this? I thought about creating a fixed array of 7
elements scanning the controls and getting the first 7 and using them. If
the array was full and the user attempted to add an 8th checkbox, again it
would prevent that from happening. So since this array would never go over
7 elements, would I really need to keep the status of all 70 checkboxes in
an array of size 70?
Perhaps I should use a Dynamic Array and check the size with Ubound?
Any other ideas for managing this many checkboxes? I'm sure that I am not
the first guy to do this.
Thanks in advance.
Alan