View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default 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