Results 1 to 10 of 10

Subscript out of range

Threaded View

  1. #1
    Registered User
    Join Date
    06-01-2009
    Location
    chicago
    MS-Off Ver
    Excel 2007
    Posts
    4

    Subscript out of range

    All:

    I'm new to VBA, however I'm an experienced programmer. I'm running the following routine:

    Sub do_dde() Dim ddeChannel As Long Dim test As Variant ddeChannel = DDEInitiate("MH", "AAPL.CCC") test = DDERequest(ddeChannel, "pVga") DDETerminate ddeChannel For i = LBound(test) To UBound(test) Worksheets("Sheet2").Cells(i, 1) = test(i) Next i End Sub
    The bolded line gives the subscript out of line error. As an additional debug step, I tried declaring another random variable called test2 (variant) and the line test2 = test(i) also returns this error.

    This is very puzzling to me, as the LBound and UBound of test (as determined by stepping through the code) are 1 and 66 returned, yet this is crashing out on the first iteration of the loop when i=1!!!

    Does anyone have any insight in to this whatsoever?! I have burned a whole day on this with no progress, and I would really appreciate any help.

    Thanks in advance, mcukier
    Last edited by mcukier; 06-02-2009 at 10:09 AM.

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