chacha
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
Thanks
Charlotte
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
Thanks
Charlotte