"Run-time error '1004'" Method 'Range' of object '_global' failed.

H

haisat

Hi,
I am trying to draw a graph using a Macro and I am getting "Run-time
error '1004'" Method 'Range' of object '_global' failed. Could any body
help me out in fixing this problem.

line
Range("A1:A340").Select
is giving the error.

..................Code.................

Sub swapmemory()
'
' swapmemory Macro
' Macro recorded 10/20/2003 by ibm user
'
' Keyboard Shortcut: Ctrl+q
'
Dim sDate As String
Dim sfile As String

sDate = Format(Date, "mmddyy")
sfile = "swapmemory_results." & sDate
ChDir "C:\new Applications\Tower-G"
Workbooks.OpenText FileName:= _
"C:\new Applications\Tower-G\" & sfile, Origin:=xlWindows, _
StartRow:=1, DataType:=xlDelimited,
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(1, 1)
Range("A1:A340").Select
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets(sfile).Range( _
"A1:A45"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:= _
sfile
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Swap Memory Results -- GLITR"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = _
"time(each unit = 5min)"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Kb"
End With
End Sub

Thanks in advance.
 

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