PC Review


Reply
Thread Tools Rate Thread

Data Range - Why wont it pick up my series values and Xaxis Values?

 
 
vankallm
Guest
Posts: n/a
 
      7th May 2004
I am trying to set my graph range to be variable, however, I kee
getting the error message at the ############### "Run time erro
"1004""
Is it simply the format of the text or is the code wrong?

Thanks For your help.



Sub Macro1()
'
' Macro1 Macro
' Macro made by NVK

Dim iLeadtime As Integer
Dim dDate As Date
Dim iUsage As Integer
Dim iCurrentStock
Dim iRange As Integer
Dim i As Integer


'get vars
iLeadtime = (Range("C2").Value)
dDate = CDate(Range("B2").Value2)
iUsage = Range("D2").Value
iCurrentStock = Range("A2").Value

iRange = 1

'MsgBox iLeadTime
'MsgBox dDate
'MsgBox iUsage

'working days-------
Dim irow, icol
irow = 1 'row 5 where the stuff is outputted
icol = 7 'Column C where the stuff is outputted
'Worksheets("Sheet1").Cells(irow, icol).Value = dDate


'stock stuff -----------------
Dim iRow2, iCol2
iRow2 = 2 'row 2 where the stuff is outputted
iCol2 = 7 'Column g where the stuff is outputted
Worksheets("Sheet1").Cells(iRow2, iCol2).Value = iCurrentStock


While iRange <= iLeadtime 'loops until it reaches the leadtim
figure


iCol2 = iCol2 + 1 'moves to next cell


'syntax: returns cell A:6
'Worksheets("Sheet1").Cells(6, 1).Value = 1

'stock row

iCurrentStock = iCurrentStock - iUsage
Worksheets("Sheet1").Cells(iRow2, iCol2).Value
iCurrentStock

iRange = iRange + 1 'increment the counter

Wend

Call Macro2(irow, icol, iLeadtime) ' pass vars to other procedure


End Sub
Sub Macro2(ByVal irow, ByVal icol, ByVal iLeadtime)
'
' Macro2 Macro
' Macro recorded 05/05/2004 by


Worksheets("Sheet1").Activate




Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("L11")
ActiveChart.SeriesCollection.NewSeries
#######################################
ActiveChart.SeriesCollection.XValues = Range(Cells(irow, icol)
Cells(irow, icol + iLeadtime))
ActiveChart.SeriesCollection.Values = Range(Cells(irow + 1, icol)
Cells(irow + 1, icol + iLeadtime))
######################################

ActiveChart.Location Where:=xlLocationAsNewSheet
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Stock / Date"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text
"Date"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Stock"
End With
ActiveChart.HasLegend = False
ActiveChart.HasDataTable = False


End Sub
::12:

--
Message posted from http://www.ExcelForum.com

 
Reply With Quote
 
 
 
 
Jon Peltier
Guest
Posts: n/a
 
      8th May 2004
See my response in your other thread.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

vankallm < wrote:

> I am trying to set my graph range to be variable, however, I keep
> getting the error message at the ############### "Run time error
> "1004""
> Is it simply the format of the text or is the code wrong?
>
> Thanks For your help.
>
>
>
> Sub Macr

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______

> '
> ' Macro1 Macro
> ' Macro made by NVK
>
> Dim iLeadtime As Integer
> Dim dDate As Date
> Dim iUsage As Integer
> Dim iCurrentStock
> Dim iRange As Integer
> Dim i As Integer
>
>
> 'get vars
> iLeadtime = (Range("C2").Value)
> dDate = CDate(Range("B2").Value2)
> iUsage = Range("D2").Value
> iCurrentStock = Range("A2").Value
>
> iRange = 1
>
> 'MsgBox iLeadTime
> 'MsgBox dDate
> 'MsgBox iUsage
>
> 'working days-------
> Dim irow, icol
> irow = 1 'row 5 where the stuff is outputted
> icol = 7 'Column C where the stuff is outputted
> 'Worksheets("Sheet1").Cells(irow, icol).Value = dDate
>
>
> 'stock stuff -----------------
> Dim iRow2, iCol2
> iRow2 = 2 'row 2 where the stuff is outputted
> iCol2 = 7 'Column g where the stuff is outputted
> Worksheets("Sheet1").Cells(iRow2, iCol2).Value = iCurrentStock
>
>
> While iRange <= iLeadtime 'loops until it reaches the leadtime
> figure
>
>
> iCol2 = iCol2 + 1 'moves to next cell
>
>
> 'syntax: returns cell A:6
> 'Worksheets("Sheet1").Cells(6, 1).Value = 1
>
> 'stock row
>
> iCurrentStock = iCurrentStock - iUsage
> Worksheets("Sheet1").Cells(iRow2, iCol2).Value =
> iCurrentStock
>
> iRange = iRange + 1 'increment the counter
>
> Wend
>
> Call Macro2(irow, icol, iLeadtime) ' pass vars to other procedure
>
>
> End Sub
> Sub Macro2(ByVal irow, ByVal icol, ByVal iLeadtime)
> '
> ' Macro2 Macro
> ' Macro recorded 05/05/2004 by
>
>
> Worksheets("Sheet1").Activate
>
>
>
>
> Charts.Add
> ActiveChart.ChartType = xlLineMarkers
> ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("L11")
> ActiveChart.SeriesCollection.NewSeries
> #######################################
> ActiveChart.SeriesCollection.XValues = Range(Cells(irow, icol),
> Cells(irow, icol + iLeadtime))
> ActiveChart.SeriesCollection.Values = Range(Cells(irow + 1, icol),
> Cells(irow + 1, icol + iLeadtime))
> ######################################
>
> ActiveChart.Location Where:=xlLocationAsNewSheet
> With ActiveChart
> .HasTitle = True
> .ChartTitle.Characters.Text = "Stock / Date"
> .Axes(xlCategory, xlPrimary).HasTitle = True
> .Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text =
> "Date"
> .Axes(xlValue, xlPrimary).HasTitle = True
> .Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Stock"
> End With
> ActiveChart.HasLegend = False
> ActiveChart.HasDataTable = False
>
>
> End Sub
> ::12::
>
>
> ---
> Message posted from http://www.ExcelForum.com/
>


 
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
Reg:Macro needed to pick up only distinct values but it picks up allthe values anshu minocha Microsoft Excel Programming 4 28th Jan 2010 06:43 PM
adjust axis range and major units in xy-chart to data series values biker Microsoft Access Forms 0 3rd Sep 2009 01:25 AM
Is there a way to give range names (especially with relative reference) for series names and series values in Excel 2007 graphs? johns_myself@yahoo.com Microsoft Excel Programming 0 16th Aug 2007 02:52 PM
loop through cells in a range and pick up corresponding cell values in another range patrice.cezzar@gmail.com Microsoft Excel Programming 9 19th Oct 2006 05:11 AM
how to pick from a range of table values jackoat Microsoft Excel Worksheet Functions 5 2nd Aug 2005 08:50 PM


Features
 

Advertising
 

Newsgroups
 


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