PC Review


Reply
Thread Tools Rate Thread

building a range for SetSourceData

 
 
cate
Guest
Posts: n/a
 
      28th Mar 2010
I am trying to build a range object to feed a chart input. I want to
move from old to new:


' OLD
myChart.SetSourceData Source:=Sheets("Main Sheet").Range( _
"DF71:IS71,DF73:IS73"), PlotBy:=xlRows

' NEW
myChart.SetSourceData Source:=ws , PlotBy:=xlRows



Here is the way I built the robj. I use the other range objects to
collect row and column info. What am I doing wrong?

Dim ws As Range
Set ws = myWs.Range( _
myWs.Range(myWs.Cells(Date_Week.row, FirstDataCol.Column),
myWs.Cells(Date_Week.row, LastDataCol.Column)), _
myWs.Range(myWs.Cells(Pool_Sum.row, FirstDataCol.Column),
myWs.Cells(Pool_Sum.row, LastDataCol.Column)))


The chart doesn't die, but the results are a mess.
Thank you

(I have verified in debug mode that the row and column numbers
returned by all ranges are correct)
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      28th Mar 2010
Since your range is correct, have you checked to make sure your data types
are the same in the range? i.e. string vs numeric?



"cate" <(E-Mail Removed)> wrote in message
news:ae6cdf7a-eae5-404b-ad3a-(E-Mail Removed)...
>I am trying to build a range object to feed a chart input. I want to
> move from old to new:
>
>
> ' OLD
> myChart.SetSourceData Source:=Sheets("Main Sheet").Range( _
> "DF71:IS71,DF73:IS73"), PlotBy:=xlRows
>
> ' NEW
> myChart.SetSourceData Source:=ws , PlotBy:=xlRows
>
>
>
> Here is the way I built the robj. I use the other range objects to
> collect row and column info. What am I doing wrong?
>
> Dim ws As Range
> Set ws = myWs.Range( _
> myWs.Range(myWs.Cells(Date_Week.row, FirstDataCol.Column),
> myWs.Cells(Date_Week.row, LastDataCol.Column)), _
> myWs.Range(myWs.Cells(Pool_Sum.row, FirstDataCol.Column),
> myWs.Cells(Pool_Sum.row, LastDataCol.Column)))
>
>
> The chart doesn't die, but the results are a mess.
> Thank you
>
> (I have verified in debug mode that the row and column numbers
> returned by all ranges are correct)



 
Reply With Quote
 
cate
Guest
Posts: n/a
 
      28th Mar 2010


They are not the same type.... I am beginning to wonder if this range
I built is being viewed as an area v/s two separate rows as in the
'Old' construct. Maybe the question should be, how do you build a
range object with multiple rows?


On Mar 28, 12:18*pm, "JLGWhiz" <JLGW...@cfl.rr.com> wrote:
> Since your range is correct, have you checked to make sure your data types
> are the same in the range? *i.e. string vs numeric?
>
> "cate" <catebekens...@yahoo.com> wrote in message
>
> news:ae6cdf7a-eae5-404b-ad3a-(E-Mail Removed)...
>
> >I am trying to build a range object to feed a chart input. *I want to
> > move from old to new:

>
> > * *' OLD
> > * *myChart.SetSourceData Source:=Sheets("Main Sheet").Range( _
> > * * * *"DF71:IS71,DF73:IS73"), PlotBy:=xlRows

>
> > * *' NEW
> > * *myChart.SetSourceData Source:=ws , PlotBy:=xlRows

>
> > Here is the way I built the robj. *I use the other range objects to
> > collect row and column info. *What am I doing wrong?

>
> > * *Dim ws As Range
> > * *Set ws = myWs.Range( _
> > * * * myWs.Range(myWs.Cells(Date_Week.row, FirstDataCol.Column),
> > myWs.Cells(Date_Week.row, LastDataCol.Column)), _
> > * * * myWs.Range(myWs.Cells(Pool_Sum.row, FirstDataCol.Column),
> > myWs.Cells(Pool_Sum.row, LastDataCol.Column)))

>
> > The chart doesn't die, but the results are a mess.
> > Thank you

>
> > (I have verified in debug mode that the row and column numbers
> > returned by all ranges are correct)


 
Reply With Quote
 
cate
Guest
Posts: n/a
 
      28th Mar 2010
Set ws = aSheet.Range("DF71:IS71, DF73:IS73")

works just fine... so it's the way I build the range object. I've got

Set ws = aSheet.Range(range, range), and I want
aSheet.Range("range, range") -- or ("string address, string address") -
or

How do you do that?

On Mar 28, 12:32*pm, cate <catebekens...@yahoo.com> wrote:
> They are not the same type.... I am beginning to wonder if this range
> I built is being viewed as an area v/s two separate rows as in the
> 'Old' construct. *Maybe the question should be, how do you build a
> range object with multiple rows?
>
> On Mar 28, 12:18*pm, "JLGWhiz" <JLGW...@cfl.rr.com> wrote:
>
> > Since your range is correct, have you checked to make sure your data types
> > are the same in the range? *i.e. string vs numeric?

>
> > "cate" <catebekens...@yahoo.com> wrote in message

>
> >news:ae6cdf7a-eae5-404b-ad3a-(E-Mail Removed)....

>
> > >I am trying to build a range object to feed a chart input. *I want to
> > > move from old to new:

>
> > > * *' OLD
> > > * *myChart.SetSourceData Source:=Sheets("Main Sheet").Range( _
> > > * * * *"DF71:IS71,DF73:IS73"), PlotBy:=xlRows

>
> > > * *' NEW
> > > * *myChart.SetSourceData Source:=ws , PlotBy:=xlRows

>
> > > Here is the way I built the robj. *I use the other range objects to
> > > collect row and column info. *What am I doing wrong?

>
> > > * *Dim ws As Range
> > > * *Set ws = myWs.Range( _
> > > * * * myWs.Range(myWs.Cells(Date_Week.row, FirstDataCol.Column),
> > > myWs.Cells(Date_Week.row, LastDataCol.Column)), _
> > > * * * myWs.Range(myWs.Cells(Pool_Sum.row, FirstDataCol.Column),
> > > myWs.Cells(Pool_Sum.row, LastDataCol.Column)))

>
> > > The chart doesn't die, but the results are a mess.
> > > Thank you

>
> > > (I have verified in debug mode that the row and column numbers
> > > returned by all ranges are correct)


 
Reply With Quote
 
cate
Guest
Posts: n/a
 
      28th Mar 2010
ah hahah.. and the answer is! You build each row range object, then
join them with union()

Set ws1 = aSheet.Range(aSheet.Cells(Date_Week.row,
FirstDataCol.Column), aSheet.Cells(Date_Week.row, LastDataCol.Column))
Set ws2 = aSheet.Range(aSheet.Cells(Pool_Sum.row,
FirstDataCol.Column), aSheet.Cells(Pool_Sum.row, LastDataCol.Column))

Set ws = Union(wsDataSource1, wsDataSource2)

Works great!


On Mar 28, 12:56*pm, cate <catebekens...@yahoo.com> wrote:
> * * Set ws = aSheet.Range("DF71:IS71, DF73:IS73")
>
> works just fine... so it's the way I build the range object. *I've got
>
> * * Set ws = aSheet.Range(range, range), and I want
> aSheet.Range("range, range") -- or ("string address, string address") -
> or
>
> How do you do that?
>
> On Mar 28, 12:32*pm, cate <catebekens...@yahoo.com> wrote:
>
> > They are not the same type.... I am beginning to wonder if this range
> > I built is being viewed as an area v/s two separate rows as in the
> > 'Old' construct. *Maybe the question should be, how do you build a
> > range object with multiple rows?

>
> > On Mar 28, 12:18*pm, "JLGWhiz" <JLGW...@cfl.rr.com> wrote:

>
> > > Since your range is correct, have you checked to make sure your data types
> > > are the same in the range? *i.e. string vs numeric?

>
> > > "cate" <catebekens...@yahoo.com> wrote in message

>
> > >news:ae6cdf7a-eae5-404b-ad3a-(E-Mail Removed)....

>
> > > >I am trying to build a range object to feed a chart input. *I wantto
> > > > move from old to new:

>
> > > > * *' OLD
> > > > * *myChart.SetSourceData Source:=Sheets("Main Sheet").Range( _
> > > > * * * *"DF71:IS71,DF73:IS73"), PlotBy:=xlRows

>
> > > > * *' NEW
> > > > * *myChart.SetSourceData Source:=ws , PlotBy:=xlRows

>
> > > > Here is the way I built the robj. *I use the other range objects to
> > > > collect row and column info. *What am I doing wrong?

>
> > > > * *Dim ws As Range
> > > > * *Set ws = myWs.Range( _
> > > > * * * myWs.Range(myWs.Cells(Date_Week.row, FirstDataCol.Column),
> > > > myWs.Cells(Date_Week.row, LastDataCol.Column)), _
> > > > * * * myWs.Range(myWs.Cells(Pool_Sum.row, FirstDataCol.Column),
> > > > myWs.Cells(Pool_Sum.row, LastDataCol.Column)))

>
> > > > The chart doesn't die, but the results are a mess.
> > > > Thank you

>
> > > > (I have verified in debug mode that the row and column numbers
> > > > returned by all ranges are correct)


 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      28th Mar 2010
Perseverence pays off!


"cate" <(E-Mail Removed)> wrote in message
news:40b28712-574c-4bdd-bc8d-(E-Mail Removed)...
ah hahah.. and the answer is! You build each row range object, then
join them with union()

Set ws1 = aSheet.Range(aSheet.Cells(Date_Week.row,
FirstDataCol.Column), aSheet.Cells(Date_Week.row, LastDataCol.Column))
Set ws2 = aSheet.Range(aSheet.Cells(Pool_Sum.row,
FirstDataCol.Column), aSheet.Cells(Pool_Sum.row, LastDataCol.Column))

Set ws = Union(wsDataSource1, wsDataSource2)

Works great!


On Mar 28, 12:56 pm, cate <catebekens...@yahoo.com> wrote:
> Set ws = aSheet.Range("DF71:IS71, DF73:IS73")
>
> works just fine... so it's the way I build the range object. I've got
>
> Set ws = aSheet.Range(range, range), and I want
> aSheet.Range("range, range") -- or ("string address, string address") -
> or
>
> How do you do that?
>
> On Mar 28, 12:32 pm, cate <catebekens...@yahoo.com> wrote:
>
> > They are not the same type.... I am beginning to wonder if this range
> > I built is being viewed as an area v/s two separate rows as in the
> > 'Old' construct. Maybe the question should be, how do you build a
> > range object with multiple rows?

>
> > On Mar 28, 12:18 pm, "JLGWhiz" <JLGW...@cfl.rr.com> wrote:

>
> > > Since your range is correct, have you checked to make sure your data
> > > types
> > > are the same in the range? i.e. string vs numeric?

>
> > > "cate" <catebekens...@yahoo.com> wrote in message

>
> > >news:ae6cdf7a-eae5-404b-ad3a-(E-Mail Removed)...

>
> > > >I am trying to build a range object to feed a chart input. I want to
> > > > move from old to new:

>
> > > > ' OLD
> > > > myChart.SetSourceData Source:=Sheets("Main Sheet").Range( _
> > > > "DF71:IS71,DF73:IS73"), PlotBy:=xlRows

>
> > > > ' NEW
> > > > myChart.SetSourceData Source:=ws , PlotBy:=xlRows

>
> > > > Here is the way I built the robj. I use the other range objects to
> > > > collect row and column info. What am I doing wrong?

>
> > > > Dim ws As Range
> > > > Set ws = myWs.Range( _
> > > > myWs.Range(myWs.Cells(Date_Week.row, FirstDataCol.Column),
> > > > myWs.Cells(Date_Week.row, LastDataCol.Column)), _
> > > > myWs.Range(myWs.Cells(Pool_Sum.row, FirstDataCol.Column),
> > > > myWs.Cells(Pool_Sum.row, LastDataCol.Column)))

>
> > > > The chart doesn't die, but the results are a mess.
> > > > Thank you

>
> > > > (I have verified in debug mode that the row and column numbers
> > > > returned by all ranges are correct)



 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      28th Mar 2010

>Perseverence pays off!


So does a spell checker.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com



On Sun, 28 Mar 2010 14:46:31 -0400, "JLGWhiz" <(E-Mail Removed)>
wrote:

>Perseverence pays off!
>
>
>"cate" <(E-Mail Removed)> wrote in message
>news:40b28712-574c-4bdd-bc8d-(E-Mail Removed)...
>ah hahah.. and the answer is! You build each row range object, then
>join them with union()
>
> Set ws1 = aSheet.Range(aSheet.Cells(Date_Week.row,
>FirstDataCol.Column), aSheet.Cells(Date_Week.row, LastDataCol.Column))
> Set ws2 = aSheet.Range(aSheet.Cells(Pool_Sum.row,
>FirstDataCol.Column), aSheet.Cells(Pool_Sum.row, LastDataCol.Column))
>
> Set ws = Union(wsDataSource1, wsDataSource2)
>
>Works great!
>
>
>On Mar 28, 12:56 pm, cate <catebekens...@yahoo.com> wrote:
>> Set ws = aSheet.Range("DF71:IS71, DF73:IS73")
>>
>> works just fine... so it's the way I build the range object. I've got
>>
>> Set ws = aSheet.Range(range, range), and I want
>> aSheet.Range("range, range") -- or ("string address, string address") -
>> or
>>
>> How do you do that?
>>
>> On Mar 28, 12:32 pm, cate <catebekens...@yahoo.com> wrote:
>>
>> > They are not the same type.... I am beginning to wonder if this range
>> > I built is being viewed as an area v/s two separate rows as in the
>> > 'Old' construct. Maybe the question should be, how do you build a
>> > range object with multiple rows?

>>
>> > On Mar 28, 12:18 pm, "JLGWhiz" <JLGW...@cfl.rr.com> wrote:

>>
>> > > Since your range is correct, have you checked to make sure your data
>> > > types
>> > > are the same in the range? i.e. string vs numeric?

>>
>> > > "cate" <catebekens...@yahoo.com> wrote in message

>>
>> > >news:ae6cdf7a-eae5-404b-ad3a-(E-Mail Removed)...

>>
>> > > >I am trying to build a range object to feed a chart input. I want to
>> > > > move from old to new:

>>
>> > > > ' OLD
>> > > > myChart.SetSourceData Source:=Sheets("Main Sheet").Range( _
>> > > > "DF71:IS71,DF73:IS73"), PlotBy:=xlRows

>>
>> > > > ' NEW
>> > > > myChart.SetSourceData Source:=ws , PlotBy:=xlRows

>>
>> > > > Here is the way I built the robj. I use the other range objects to
>> > > > collect row and column info. What am I doing wrong?

>>
>> > > > Dim ws As Range
>> > > > Set ws = myWs.Range( _
>> > > > myWs.Range(myWs.Cells(Date_Week.row, FirstDataCol.Column),
>> > > > myWs.Cells(Date_Week.row, LastDataCol.Column)), _
>> > > > myWs.Range(myWs.Cells(Pool_Sum.row, FirstDataCol.Column),
>> > > > myWs.Cells(Pool_Sum.row, LastDataCol.Column)))

>>
>> > > > The chart doesn't die, but the results are a mess.
>> > > > Thank you

>>
>> > > > (I have verified in debug mode that the row and column numbers
>> > > > returned by all ranges are correct)

>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      29th Mar 2010
Chip, if that was my worst mistake, I would be very happy!


"Chip Pearson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
>>Perseverence pays off!

>
> So does a spell checker.
>
> Cordially,
> Chip Pearson
> Microsoft Most Valuable Professional,
> Excel, 1998 - 2010
> Pearson Software Consulting, LLC
> www.cpearson.com
>
>
>
> On Sun, 28 Mar 2010 14:46:31 -0400, "JLGWhiz" <(E-Mail Removed)>
> wrote:
>
>>Perseverence pays off!
>>
>>
>>"cate" <(E-Mail Removed)> wrote in message
>>news:40b28712-574c-4bdd-bc8d-(E-Mail Removed)...
>>ah hahah.. and the answer is! You build each row range object, then
>>join them with union()
>>
>> Set ws1 = aSheet.Range(aSheet.Cells(Date_Week.row,
>>FirstDataCol.Column), aSheet.Cells(Date_Week.row, LastDataCol.Column))
>> Set ws2 = aSheet.Range(aSheet.Cells(Pool_Sum.row,
>>FirstDataCol.Column), aSheet.Cells(Pool_Sum.row, LastDataCol.Column))
>>
>> Set ws = Union(wsDataSource1, wsDataSource2)
>>
>>Works great!
>>
>>
>>On Mar 28, 12:56 pm, cate <catebekens...@yahoo.com> wrote:
>>> Set ws = aSheet.Range("DF71:IS71, DF73:IS73")
>>>
>>> works just fine... so it's the way I build the range object. I've got
>>>
>>> Set ws = aSheet.Range(range, range), and I want
>>> aSheet.Range("range, range") -- or ("string address, string address") -
>>> or
>>>
>>> How do you do that?
>>>
>>> On Mar 28, 12:32 pm, cate <catebekens...@yahoo.com> wrote:
>>>
>>> > They are not the same type.... I am beginning to wonder if this range
>>> > I built is being viewed as an area v/s two separate rows as in the
>>> > 'Old' construct. Maybe the question should be, how do you build a
>>> > range object with multiple rows?
>>>
>>> > On Mar 28, 12:18 pm, "JLGWhiz" <JLGW...@cfl.rr.com> wrote:
>>>
>>> > > Since your range is correct, have you checked to make sure your data
>>> > > types
>>> > > are the same in the range? i.e. string vs numeric?
>>>
>>> > > "cate" <catebekens...@yahoo.com> wrote in message
>>>
>>> > >news:ae6cdf7a-eae5-404b-ad3a-(E-Mail Removed)...
>>>
>>> > > >I am trying to build a range object to feed a chart input. I want
>>> > > >to
>>> > > > move from old to new:
>>>
>>> > > > ' OLD
>>> > > > myChart.SetSourceData Source:=Sheets("Main Sheet").Range( _
>>> > > > "DF71:IS71,DF73:IS73"), PlotBy:=xlRows
>>>
>>> > > > ' NEW
>>> > > > myChart.SetSourceData Source:=ws , PlotBy:=xlRows
>>>
>>> > > > Here is the way I built the robj. I use the other range objects to
>>> > > > collect row and column info. What am I doing wrong?
>>>
>>> > > > Dim ws As Range
>>> > > > Set ws = myWs.Range( _
>>> > > > myWs.Range(myWs.Cells(Date_Week.row, FirstDataCol.Column),
>>> > > > myWs.Cells(Date_Week.row, LastDataCol.Column)), _
>>> > > > myWs.Range(myWs.Cells(Pool_Sum.row, FirstDataCol.Column),
>>> > > > myWs.Cells(Pool_Sum.row, LastDataCol.Column)))
>>>
>>> > > > The chart doesn't die, but the results are a mess.
>>> > > > Thank you
>>>
>>> > > > (I have verified in debug mode that the row and column numbers
>>> > > > returned by all ranges are correct)

>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using other than Range as SetSourceData method argument CKa Microsoft Excel Charting 4 1st Jun 2010 03:06 AM
problem building Function with worksheet name and range caroline Microsoft Excel Programming 2 26th Oct 2009 07:20 PM
When building a chart Dates are been included that are not in thedate range Sh0t2bts Microsoft Excel Worksheet Functions 1 14th Oct 2009 03:58 PM
Help with SetSourceData EAB1977 Microsoft Excel Programming 1 12th Oct 2009 07:16 PM
setSourcedata tony wong Microsoft Excel Programming 2 22nd Feb 2007 02:06 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:51 AM.