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

V

vankallm

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:
 
J

Jon Peltier

See my response in your other thread.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
Tutorials and Custom Solutions
http://PeltierTech.com/
_______
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/
_______
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top