LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Trouble using the Cells() function

I removed some of the unimportant code and defines.

rng_Ax = Array(4, 3, 3, 3, 6, 9, 3, 6, 9, _
3, 2, 7, 12, 2, 7, 12, 2, 7, 4, _
3, 6, 9, 3, 6, 9, 2, 2, 2) ' 1-3, 4, 5-9
rng_Ay = Array(5, 5, 5, 5, 5, 5, 5, 5, 5, _
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, _
5, 5, 5, 5, 5, 5, 4, 5, 5)
rng_Bx = Array(4, 5, 3, 5, 8, 11, 5, 8, 11, _
4, 6, 11, 16, 6, 11, 16, 6, 11, 4, _
5, 8, 11, 5, 8, 11, 4, 6, 6)
rng_By = Array(5, 5, 5, 5, 5, 5, 5, 5, 5, _
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, _
5, 5, 5, 5, 5, 5, 4, 5, 5)

For gr_nm = 1 To 28
If range_create.Offset(gr_nm - 1, 1).Value = 1 Then

' Create and setup chart
range_create.Offset(gr_nm - 1, 2) = 1
Set WS = Worksheets(tabs(t_num(gr_nm - 1)))
Set chxxx = ActiveWorkbook.Charts.Add

' Setup source range
Set ch_rng = WS.Range(WS.Cells(rng_Ax(gr_num),
rng_Ay(gr_num)), _
WS.Cells(rng_Bx(gr_num),
rng_By(gr_num)))
chxxx.SetSourceData Source:=WS.Range(ch_rng,
ch_rng.Offset(e_val(gr_nm))), _
PlotBy:=xlColumns

' Setup series
For s_cnt = 0 To 4
If s_cnt + 1 <= DWS.Cells(gr_nm + 2, 2) Then
With chxxx.SeriesCollection(s_cnt + 1)
End With
End If
Next s_cnt
End If
Next gr_nm

The portion of the code that isn't working is the setting of ch_rng. When I
get to the following code, I get an error...

With chxxx.SeriesCollection(s_cnt + 1)

I get the error because the following code is not giving me the desired
amount.
WS.Range(WS.Cells(rng_Ax(gr_num), rng_Ay(gr_num))

In this example;
rng_Ax(gr_num) = 4
rng_Ay(gr_num) = 5
rng_Bx(gr_num) = 4
rng_By(gr_num) = 5

I want the original code to end producing this

Set ch_rng = WS.Range(Range("D5"), Range("D5"))

and

chxxx.SetSourceData Source:=WS.Range(Range("D5"),
Range("D5").Offset(e_val(gr_nm)))


Ax, Ay, Bx, and By vary for different cases, as can be seen in the defines.
However, I get the following result:

Set ch_rng = WS.Range(6043395, 6043395)

Why does WS.Cells(rng_Ax(gr_num), rng_Ay(gr_num)) result in those numbers,
and not in "D5"?

Sorry if this is confusing, but I am almost certain there is a simple fix I
haven't thought of or tried. Thanks, in advance, for all help I receive.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
min function trouble [email protected] Excel Programming 4 January 4th 08 11:51 AM
Having trouble with function. Teethless mama Excel Worksheet Functions 1 March 28th 07 02:11 AM
IF function trouble raye Excel Worksheet Functions 2 August 28th 05 01:43 AM
IF FUNCTION Trouble J. Cornor Excel Programming 3 July 12th 05 10:26 PM
function trouble hans[_3_] Excel Programming 1 February 7th 05 05:19 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"