Consulting

Results 1 to 5 of 5

Thread: runtime error 438

  1. #1
    VBAX Regular
    Joined
    Jan 2008
    Posts
    9
    Location

    runtime error 438

    Hopefully some can help me this code for my FYP

    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".
    [vba]
    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
    [/vba] any help would be great
    Thanks
    Charlotte

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Try this

    [vba]

    Sheets("Sheet1").Range("B4:J" & nGraph).Copy
    Sheets("Sheet2").Activate
    ActiveSheet.Paste Link:=True
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Jan 2008
    Posts
    9
    Location
    thanks xld
    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.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Do you mean get rid of that item from the chart, or just stop the chart from displaying a zero value?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Regular
    Joined
    Jan 2008
    Posts
    9
    Location
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •