Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am creating a pie chart and I only want to plot the ranges that correspond to values greater than 0. So I'd like to loop over the possible entries and set my chart range to correspong to only those that are non- zero. I'm assuming that I'll need to add ranges somehow to do this, but I can't seem to get it right. How do you add ranges so that they can be used for charts? Here is an example of what I mean: | A | B _________________________ 1 | name1 | 5 2 | name2 | 0 3 | name3 | 3 4 | name4 | 7 So I'd want the range to be "A1:B1,A3:B4" for my pie chart. I'd like to loop over rows 1 through 4, and add the ranges corresponding to the non- zero entries in column B. Here is the loop that I created: For i = 3 To 10 If Worksheets("Program").Cells(i, 12) 0 Then Set PieChartRange = PieChartRange + Worksheets("Program").Range (Cells(i, 11), Cells(i, 12)) End If Next i But the statement 'Set PieChartRange = ...' doesn't work. I'd like to use that variable in the following block: With ActiveSheet.ChartObjects.Add _ (Left:=440, Width:=330, Top:=495, Height:=220) With .Chart .SetSourceData Source:=ActiveSheet.Range(PieChartRange.Address) '.... '.... I'd greatly appreciate any help. -- Message posted via http://www.officekb.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
adding numbers that contain ranges | Excel Worksheet Functions | |||
Adding Non-Contiguous Ranges | Excel Discussion (Misc queries) | |||
adding ranges | Excel Discussion (Misc queries) | |||
adding named ranges | New Users to Excel | |||
Adding Cell Values to Ranges | Excel Programming |