problem related to VB Macro....

R

roger

Hi
I wanted to plot a data using macro which gives the 'run time error
1004' (Method 'Range' of object '_Global' failed)

can somebody help me in debugging the error.
Thanks


Sub Macro1()
'
' Macro1 Macro
' Macro recorded 3/30/2007 by Pkumar
'
' Keyboard Shortcut: Ctrl+m
'




Charts.Add
ActiveChart.ChartType = xlXYScatterLines

Dim columnValue As Variant

columnValue = Range("UV and UV & Ozone!columnValue") 'get
Column values



ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries



ActiveChart.SeriesCollection(1).XValues = _
"=('UV and UV & Ozone'!R18C3,'UV and UV & Ozone'!R19C3,'UV and
UV & Ozone'!R21C3,'UV and UV & Ozone'!R23C3,'UV and UV & Ozone'!
R25C3,'UV and UV & Ozone'!R27C3)"
ActiveChart.SeriesCollection(1).Values = _
"=('UV and UV & Ozone'!R18C" & columnValue & ",'UV and UV &
Ozone'!R19C" & columnValue & ",'UV and UV & Ozone'!R21C" & columnValue
& ",'UV and UV & Ozone'!R23C" & columnValue & ",'UV and UV & Ozone'!
R25C" & columnValue & ",'UV and UV & Ozone'!R27C" & columnValue & ")"
ActiveChart.SeriesCollection(1).Name = "=""UV"""
ActiveChart.SeriesCollection(2).XValues = _
"=('UV and UV & Ozone'!R18C3,'UV and UV & Ozone'!R19C3,'UV and
UV & Ozone'!R21C3,'UV and UV & Ozone'!R23C3,'UV and UV & Ozone'!
R25C3,'UV and UV & Ozone'!R27C3)"
ActiveChart.SeriesCollection(2).Values = _
"=('UV and UV & Ozone'!R18C" & columnValue & ",'UV and UV &
Ozone'!R20C" & columnValue & ",'UV and UV & Ozone'!R22C" & columnValue
& ",'UV and UV & Ozone'!R24C" & columnValue & ",'UV and UV & Ozone'!
R26C" & columnValue & ",'UV and UV & Ozone'!R28C" & columnValue & ")"
ActiveChart.SeriesCollection(2).Name = "=""UV & Ozone"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="UV and UV &
Ozone"


Range("UV and UV & Ozone!columnValue") = columnValue + 2
'store next row values


With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "fucking plot"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time
step"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "kuch
bhi"
End With
End Sub
 

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