View Full Version : runtime error 438

01-28-2008, 10:41 AM
Hopefully some can help me this code for my FYP:banghead:

I have an error in the last line. I am trying to copy a range of cells from Sheet1 to Sheet2. The range is ("B4:J" & nGraph).
I get a "run-time error '438': Object doesn't support this property or method".

Sub InsertMembers()

Dim nMembers As Integer
Dim nNodes As Integer
Dim startPoint As Range
Dim nGraph As Integer

nMembers = CInt(Sheets("Sheet1").Range("C1"))
nNodes = CInt(Sheets("Sheet1").Range("C2"))
nGraph = CInt(Sheets("Sheet1").Range("L2"))

Set startPoint = Sheets("Sheet1").Range("B4") ' A3 is where we insert rows at

For i = 1 To nMembers
startPoint.Offset(i, 0).Insert
startPoint.Offset(i, 0) = "Member " & i
startPoint.Offset(i, 1) = "5"
startPoint.Offset(i, 2) = Round(i / 2 + 0.5)
startPoint.Offset(i, 3) = Round(i / 2 + 1.5)
Next i

For i = 1 To nNodes
startPoint.Offset(i, 5) = "Node " & i
startPoint.Offset(i, 6) = "0" 'X Coordinate
startPoint.Offset(i, 7) = "1" 'Y Coordinate
startPoint.Offset(i, 8) = "?" 'Can I do Z?
Next i

'Copy Data from Input Sheet to Graph Sheet
Sheets("Sheet1").Range("B4:J" & nGraph).Copy
Sheets("Sheet2").Range("A1").Paste Link:=True 'Problem line

End Sub
any help would be great

01-28-2008, 10:50 AM
Try this

Sheets("Sheet1").Range("B4:J" & nGraph).Copy
ActiveSheet.Paste Link:=True

01-28-2008, 11:28 AM
thanks xld :thumb
some of the cells i have linked are empty in sheet1. how can i get rid of the zeros in the corresponding cells in sheet2? I want to use this data for a chart.

01-28-2008, 03:02 PM
Do you mean get rid of that item from the chart, or just stop the chart from displaying a zero value?

02-28-2008, 08:23 AM
I didn't want the graph to include the zeros, but my supervisor has added a new dimension to my project, which makes this problem redundant. Thanks for your help though