+ Reply to Thread
Results 1 to 2 of 2

vba conditional loops

  1. #1
    Benoit
    Guest

    vba conditional loops

    This one should be easy for someone used to vba.
    I've got three named ranges on the same sheet called "DataDownload"
    (LSRatio, LongPrice, ShortPrice).
    LSRatio is the range I want to populate
    LongPrice and ShortPrice are price series going down different columns.
    I want to do a loop in the LSRatio range that first checks that LongPrice
    and ShortPrice are not empty, and if this is the case, calculate LSRatio as
    LongPrice/ShortPrice until I reach the point where LongPrice and ShortPrice
    end (ie cells become empty) at which point the procedure ends.
    Any help would be greatly appricated

  2. #2
    Tom Ogilvy
    Guest

    RE: vba conditional loops

    Assume Longprice and Shortprice will be the same size and populated to the
    same extent

    i = 0
    for each cell in Rane("shortprice")
    i = i + 1
    if not isempty(cell) then
    range("lsratio")(i).Value = Range("Longprice")(i).Value/cell.Value
    else
    exit for
    end if
    Next

    --
    Regards,
    Tom Ogilvy


    "Benoit" wrote:

    > This one should be easy for someone used to vba.
    > I've got three named ranges on the same sheet called "DataDownload"
    > (LSRatio, LongPrice, ShortPrice).
    > LSRatio is the range I want to populate
    > LongPrice and ShortPrice are price series going down different columns.
    > I want to do a loop in the LSRatio range that first checks that LongPrice
    > and ShortPrice are not empty, and if this is the case, calculate LSRatio as
    > LongPrice/ShortPrice until I reach the point where LongPrice and ShortPrice
    > end (ie cells become empty) at which point the procedure ends.
    > Any help would be greatly appricated


+ 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