charging rhinos
New Member
- Joined
- Jun 23, 2011
- Messages
- 4
Hello to all. I have been assigned a vba project that requires me to make some rather complicated graphs. I'll try my best to explain:
The row portion of the sheet I use for my data has 39 entries. These end up being the legend items in a stacked column graph. The issue i have to fix is that the graphs must be monstrous in size to fit all 39 of those legend items, and most of them are empty and not being used in the graph. I would like to select only the items that have data in that row, and create the graph from a selection of those lines alone. This is the code, with comments, that I have thus far. I am attempting to 1) find the rows with data in them, then 2) select the portion of the row that will be used for the graph, and 3) find the next row with data and add it to that first selection, repeating until all rows have been checked.
I know that the MultiRange range variable is not defined in this block of code, which I could do if needed. It just seems like there must be a FAR getter way to do this. I've tried it with the Union function, and it gives me trouble, since the vast majority of the 39 rows if items are empty and cause Union to fail.
Thanks very much in advance.
The row portion of the sheet I use for my data has 39 entries. These end up being the legend items in a stacked column graph. The issue i have to fix is that the graphs must be monstrous in size to fit all 39 of those legend items, and most of them are empty and not being used in the graph. I would like to select only the items that have data in that row, and create the graph from a selection of those lines alone. This is the code, with comments, that I have thus far. I am attempting to 1) find the rows with data in them, then 2) select the portion of the row that will be used for the graph, and 3) find the next row with data and add it to that first selection, repeating until all rows have been checked.
Code:
Dim CurrentRange As Range
Dim MultiRange As Range
For i = 1 To 39 'Find all rows with issue marks at any point and add them to the selected range
Range("M" & i + 3).Select 'this is the totals column where i determine if the row has data in it
If ActiveCell.Value > 0 Then
Range("A" & i + 3, "L" & i + 3).Select 'this selects the data needed for the chart to display properly
Set CurrentRange = Range("A" & i + 3, "L" & i + 3) 'save the selection as a range
Set MultiRange = MultiRange + CurrentRange 'add the currently selected range to the main range to be used in the graph
End If
Next i
Thanks very much in advance.