+ Reply to Thread
Results 1 to 2 of 2

"Method 'Range' of object '_Global' Failed"

Hybrid View

  1. #1
    Registered User
    Join Date
    12-22-2006
    Posts
    1

    "Method 'Range' of object '_Global' Failed"

    Hi ,


    The Code which i have paste here works sometime but most of the time it gives me the error "Method 'Range' of object '_Global' Failed" in the statement "Range(y, y).Value = z". and I tried to debug many time but occassionally it's working.

    Please tell me what's the problem:

    Function yieldCurveGetData()
    Dim CurveString
    Dim i As Integer
    Dim x As Integer
    arrayData = "1,0.0618,2,0.0628,3,0.0638,4,0.0648,5,0.0658,6,0.0668,7,0.0678,8,0.0688,9,0.0698,11,0.0708,12,0.0718,13,0.0728,14,0.0738,15,0.0748,16,0.0758,17,0.0768,18,0.0778,19,0.0788,20,0.0798,21,0.0808"
    CurveString = Split(arrayData, ",")
    i = -1
    For x = 1 To (UBound(CurveString) / 2)
    i = i + 1
    y = "A" & x
    z = """" & CurveString(i) & """"
    Range(y, y).Value = z
    i = i + 1
    m = "B" & x
    n = """" & CurveString(i) & """"
    Range(m, m).Value = n
    Next x
    End Function


    Regards,
    Gnanaprakash

  2. #2
    Forum Contributor
    Join Date
    03-13-2005
    Posts
    6,195
    Quote Originally Posted by gnanaprakash
    Hi ,


    The Code which i have paste here works sometime but most of the time it gives me the error "Method 'Range' of object '_Global' Failed" in the statement "Range(y, y).Value = z". and I tried to debug many time but occassionally it's working.

    Please tell me what's the problem:

    Function yieldCurveGetData()
    Dim CurveString
    Dim i As Integer
    Dim x As Integer
    arrayData = "1,0.0618,2,0.0628,3,0.0638,4,0.0648,5,0.0658,6,0.0668,7,0.0678,8,0.0688,9,0.0698,11,0.0708,12,0.0718,13,0.0728,14,0.0738,15,0.0748,16,0.0758,17,0.0768,18,0.0778,19,0.0788,20,0.0798,21,0.0808"
    CurveString = Split(arrayData, ",")
    i = -1
    For x = 1 To (UBound(CurveString) / 2)
    i = i + 1
    y = "A" & x
    z = """" & CurveString(i) & """"
    Range(y, y).Value = z
    i = i + 1
    m = "B" & x
    n = """" & CurveString(i) & """"
    Range(m, m).Value = n
    Next x
    End Function


    Regards,
    Gnanaprakash
    Not sure what you are trying to do but as
    Option Explicit
    
    Sub yieldCurveGetData()
    Dim arraydata As String, m As String, n As String, y As String, z As String
    Dim CurveString
    Dim x As Long
    Dim i As Integer
    arraydata = "1,0.0618,2,0.0628,3,0.0638,4,0.0648,5,0.0658,6,0. 0668,7,0.0678,8,0.0688,9,0.0698,11,0.0708,12,0.071 8,13,0.0728,14,0.0738,15,0.0748,16,0.0758,17,0.076 8,18,0.0778,19,0.0788,20,0.0798,21,0.0808"
    CurveString = Split(arraydata, ",")
    i = -1
    For x = 1 To (UBound(CurveString) / 2)
    i = i + 1
    y = "A" & x
    z = """" & CurveString(i) & """"
    Range(y).Value = z
    i = i + 1
    m = "B" & x
    n = """" & CurveString(i) & """"
    Range(m, m).Value = n
    Next x
    End Sub
    it puts 1 to 21, omitting number 10, in quotes in column A

    Hope this hekps
    ---
    Si fractum non sit, noli id reficere.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1