Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loops... Willabo Excel Discussion (Misc queries) 2 June 14th 06 04:08 PM
do loops saravanan Excel Worksheet Functions 0 June 13th 06 10:53 AM
Do loops within Do loops Linking to specific cells in pivot table Excel Programming 4 April 14th 05 08:47 AM
Do Loops No Name Excel Programming 1 July 20th 04 04:47 PM
help with loops Rick B[_6_] Excel Programming 8 January 28th 04 12:32 AM


All times are GMT +1. The time now is 02:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"