SRAutomater Posted December 13, 2007 Posted December 13, 2007 Hi everyone, I have an excel spreadsheet I would like to turn into some pie charts. I am having trouble selecting noncontiguous ranges though. In the first row, I have a header: name, state1,state2, state3, etc. The subsequent rows contain the name of each individual, and a number under each state. If I do: $obj = _ExcelBookOpen($FilePath) Local $FrequencyChart = $obj.Charts.Add With $FrequencyChart .SetSourceData($obj.Worksheets("").Range($obj.Worksheets("SE" ).Cells(1, 2), $obj.Worksheets("SE" ).Cells(2, 7))) EndWith Then everything works fine for the first person, and the slices of the pie get labeled correctly: state1, state2, state3, etc. I want to make a graph for each person though so I need to select 1,2 through 1, 7 and also x,2 through x,7. So I need help with either, make a non-contiguous selection, or changing the labels on the datasets afterwards. Any ideas?
SRAutomater Posted December 18, 2007 Author Posted December 18, 2007 Hi everyone, I have an excel spreadsheet I would like to turn into some pie charts. I am having trouble selecting noncontiguous ranges though. In the first row, I have a header: name, state1,state2, state3, etc. The subsequent rows contain the name of each individual, and a number under each state. If I do: $obj = _ExcelBookOpen($FilePath) Local $FrequencyChart = $obj.Charts.Add With $FrequencyChart .SetSourceData($obj.Worksheets("").Range($obj.Worksheets("SE" ).Cells(1, 2), $obj.Worksheets("SE" ).Cells(2, 7))) EndWith Then everything works fine for the first person, and the slices of the pie get labeled correctly: state1, state2, state3, etc. I want to make a graph for each person though so I need to select 1,2 through 1, 7 and also x,2 through x,7. So I need help with either, make a non-contiguous selection, or changing the labels on the datasets afterwards. Any ideas? I got it to work this way: $header = $obj.Worksheets("Statistics").Range("a1:g1") $data = $obj.Worksheets("Statistics").Range("a2:g2") $obj.Charts.Add.setSourceData($obj.Union($header, $data))
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now