View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Wim R.M. Dekeyser Wim R.M. Dekeyser is offline
external usenet poster
 
Posts: 2
Default Excel 2007 VBA - looping through scenarios not possible?

Hi,
I have a number of scenarios that I need to perform some calculations on.
I am trying to keep the code short by having a for - next loop running
through all the scenarios.

I am not having much luck getting that to work, though.
Shouldn't the following work?

For intLooping = 1 To 20
Scenarios(intLooping).Show
Next


The following, on the other hand, does work (but doesn't do any good).

For intScenNr = 1 To 20
arrScenarios(intScenNr - 1) = Scenarios(intScenNr).Name
Next
MsgBox Scenarios(1).Name & " - to - " & Scenarios(6).Name
MsgBox arrScenarios(0) & " - to - " & arrScenarios(5)

Thanks for any ideas!

cheers,
wim