
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
Bookmarks