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


0
Wim
4/20/2010 8:36:00 AM
excel.programming 6508 articles. 2 followers. Follow

1 Replies
838 Views

Similar Articles

[PageSpeed] 42

sorry about that one.
It helps to turn off protection on the sheet first.

cheers,
wim

"Wim R.M. Dekeyser" <firstAtlastDotorg> wrote in message 
news:O79nCSG4KHA.4336@TK2MSFTNGP04.phx.gbl...
> 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
>
> 


0
Wim
4/20/2010 9:44:55 AM
Reply:

Similar Artilces:

Pasting data from Excel
Hello everyone, I'm not sure if I should be posting this question here or in the Excel forum but here goes. Is it possible to copy data from multiple cells in Excel and then paste them into multiple lines of the criteria section of an Access query? For example, Given cells and values: A1- 1 A2- 2 A3- 3 I would like to be able to copy this data from Excel and paste it into an Access query like : Criteria: 1 or: 2 3 I am using Access 2002 SP3 and Exc...

Excel Drop Down Box
I'm trying to edit an excel worksheet that has drop down boxes. However, the drop down boxes are not typical forms. These drop dow boxes appear to be normal cells (They contain text). When I click o the box, a little gray box shows up w/ a down arrow to the right of th cell. However, if you right click on the cell, there aren't an property options that are displayed. I was wondering if anybody had any idea what kind of drop down box thi is. How can I edit or create one -- Message posted from http://www.ExcelForum.com It sounds like it's under Data|Validation. chris313 wr...

How to use outlook address in Excel
Hello, I have an Excel sheet which I use as an invoicing-application. I would like to retrieve address-data from Outlook where I keep all my contact-data of my customers. So, I want to select a customer from my Outlook contactlist when I am writing a new invoice in Excel. In Word, I have a macro which does this, but unfortunately the Application.GetAddress does not work in Excel. Can somebody help me ? "Henny Slokker" wrote: > Hello, > > I have an Excel sheet which I use as an invoicing-application. I would like > to retrieve address-data from Outlook where I...

how to select multiple text boxes in excel for formatting
I am trying to select multiple text boxes for formatting the font but seem unable to select all of them other than to click on each one individually. Is there an easy way to select all of the text boxes at once? To select multiple objects on the sheet -- Click on one object Hold the Ctrl key, and click on additional objects To select all the objects on the sheet -- Choose Edit>Go To, click Special Select Objects, click OK Or, to work with specific objects, you can add the 'Select Multiple Objects' tool to one of your toolbars: Choose Tools>Customize Select the Commands tab...

Compatibility Pack for Office 2007
This may be a stupid question, but... We are in the process of migrating from Office 2003 to Office 2007. We had deployed the Compatibility Pack to all our Office 2003 users a year or more ago so they could read documents created outside our company. My question is... Is there any need or value to keep the Compatibility Pack installed after installing Office 2007? Thanks, Tom In article <OP$RtKsmKHA.6096@TK2MSFTNGP02.phx.gbl>, Tom K wrote: > This may be a stupid question, but... > > We are in the process of migrating from Office 2003 to Office 200...

excel margin issues on landscape
When I print a spreadsheet I cant get it to print to the full page - it prints smaller unlike older excel program. Also when i set the margins for a spreadsheet the left hand margin wont move over to the edge of page like right hand side? In Page Setup: If you are using the Scaling option to print to a certain number of pages wide by pages tall and/or you are using the columns to repeat at left, try: - clearing the number of pages tall value (so that it is blank), and/or - if you are printing to one page wide, remove the columns to repeat at left Simon "Peter MB" wrote: >...

Excel macro list
In Excel 2003 I used to be able to list all macros in a workbook by pressing Alt+F8. Now all I get is a series of ribbon help letters... What's changed? Is there still a way of accessing macros via Alt+F8? Any suggestions appreciated. Hi, ALT+F8 works for me in E2007. What do you mean by 'I get is a series of ribbon help letters' Mike "pbaker6" wrote: > In Excel 2003 I used to be able to list all macros in a workbook by pressing > Alt+F8. Now all I get is a series of ribbon help letters... What's changed? > Is there still a way of...

2007 Schema Prep #2
I extended my AD last night for 2007 and have a few questions to verify it was successful: I have a root domain (domain.local) that houses my schema master and a child domain (domain.net) that has Exchange 2003. I ran setup /prepareAD then ran setup /preparedomain: domain.net and both said they completed successfully. However, I was expecting to see the new OU (Microsoft Exchange Security Groups) in my child domain. It is present in my root domain. Is that all correct? In my child domain I now have a new global security group call Exchange Install Domain Servers. Last thing, the D...

Can I only allow printing to pdf in Excel?
I have created a template in Excel which has been set up so that the layout is perfect when printing to pdf (which is how the document will mostly be used) but the layout changes if printing direct to our printer. Is there a way that I can ONLY allow printing to pdf from this document? Hello You may consider using some VBA to achieve this. One way is to use the Workbook_BeforePrint event and specify the pdf printer in the PrintOut method, eg: Private Sub Workbook_BeforePrint(Cancel As Boolean) ActiveSheet.PrintOut copies:=1, ActivePrinter:="CutePDF Writer on CPW2:" End Sub Pl...

query will not write to excel
I have set up a query to a Foxpro .dbf file in a database from excel. When I tell Excel to import the data it it appears to be working but never seems to return the data. Running the same query via msquery.exe returns the data with no problem. Can anyone tell me what the problem is ? ...

EXCEL FORMULA #28
Good afternoon, I'm trying to fine a formula which would show me how much money I would save on a mortgage if I were to pay additional principal each month--in addition to paying the additional principal how long would it take to pay off. I'm looking at a 160k mortgage at 7.5 for 30 years. I'll like to pay this off as soon as possible by paying additional principal each month. There are tons of free templates at: http://office.microsoft.com/en-us/default.aspx Maybe you'll find something you like. Kam1999i wrote: > > Good afternoon, > > I'm ...

OLE: Excel.Application
Hello, in VB.Net, I use Excel to display results : dim xl as new Excel.Application // creates an Excel process // snip (putting values into cells) xl.Visible = true If the user closes the Excel file and then my program, the Excel process is killed in memory, which is good. If the user closes my program first and then the Excel file, the Excel process remains in memory ! How can I make sure the process will be killed ? Thanks ! Hi You need to set xl.quit (and before that ensure that excel doesn't halt and ask things like "save changes?" on quitting) somewhere in your p...

Export relationship information from Visio to Excel
Hello all, Is there a way to export information regarding relationships from a visio diagram to an excel spreadsheet? In addition, is there a way to tell the excel spreadsheet to eliminate or change a relationship and for that action to be applied onto the visio diagram? thanks, ivan as a general answer I'd have to say "no, not without custom code". You didn't define what you meant as a relationship. al "Ivan Salas" <IvanSalas@discussions.microsoft.com> wrote in message news:6332A594-E4AF-4E8B-BA2D-7A4BC17962B3@microsoft.com... > Hello all, > &...

startup excel euro symbol
when i digit € symbol inside any application excel 2007 automacic startup and for me is impossible to use this symbol anywhere, i use windows xp professional ..have you a response to solve this problem? thanks ...

Word problems 2003 and 2007 version
hey everyone both on my main computer and my brothers laptop word isnt working! its so annoying! on my desktop PC i have windows xp and word 2003. after getting a virus which stopped the internet from working i had to do a system restore - which got rid of the virus. but when i click on word it says that "this shortcut only applies to installed products", and when i go to word through program files it says "this product is not installed on this user" - but there is no setup thing i can press - will i need the disc maybe? on my bro's laptop he got the sa...

Excel 2003 Print Issue
I have created a spreadsheet to help with a university engineering assignment and I have added a worksheet that is basically an automatically generated report of all the calculations. I have set the Print Area up in such a way so that the results are printed out in well defined pages (e.g. page 1: title page, page 2: summary of input variables, page 3: summary of calculation results etc). The report is arranged vertically in the worksheet, so the pages are 'stacked' on top of each other. It prints out fine in Excel 2000 and 2002 but I recently upgraded to Excel 2003 and now find tha...

excel 2000 message
excel 2000 message - 'cannot use object linking and embedding' Were they hit by the MSBlast worm? One poster (Lutz Meyer) guessed that this was the cause of his problems. I haven't seen any confirmation/denial, but you may want to read his post: http://groups.google.com/groups?threadm=3F3971AF.FA4490F5%40msn.com Post back with your results. I'm curious if that was the problem. (It's come up quite a few times since MSBlast hit.) bill bootle wrote: > > excel 2000 message - 'cannot use object linking and > embedding' -- Dave Peterson ec35720@msn.c...

Excel Graphing Line References off when chart is a sheet.
I have noticed that when any graph is created in EXCEL and you hover you mouse over the dataline you receive that corect response. If you convert the chart to a sheet, the hover of the data line is now not representative of the the y axis directly below it. The data being graphed is correct now the hover represents the "series" (x-Axis) correctly but does not represent the "Point" (y-axis) correctly at all. Tne Y-axis datapoint reference is wrong. Any help? ...

Editable Excel Spreadsheet Online?
Hi, I tried to recent find information on this, but could find very little. How difficult would it be to host an excel spreadsheet online where visitors to the site can directly view and edit it? Right now, I can upload the spreadsheet to our web site and visitors can view it, but if they edit it, they can only save it to their local drive. I would like the users to be able to save the copy on the server. What would be involved in something like this? I assume for starters (if it's do-able) we'd need Windows hosting (we're not hosting ourselves) and some ASP support. Any de...

SpellCheck Will it work on the Access 2007 Runtime?
I have a program that I have compiled. It has the following. Private Sub cmdSpellCheck_Click() Me.Call_Notes.SetFocus RunCommand acCmdSpelling End Sub Is this going to work on a runtime or will I need a full version of Access to use it? You can simulate using the runtime of A2007 quite easily for testing. To do it, change the extension of the file from accdb to accdr. Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia "Avid Fan" <me@privacy.net> wrote in message news:ulRyIhQ4KHA.4804@TK2MSFTNGP04.phx.gbl... >I have a program t...

help
Hi, I'm trying to turn the warning message off when I use: Cells.Replace What:="Z Divisional Totals", Replacement:="Divisional Totals", LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False Second part is: Is there a way to check either the column and rows filled to create border where is pointed to "APPLYBORDER". Your help would be much apprecated. r = Range("A10").End(xlDown).Row ApplyBorder Range("A10", "A" & r) ApplyBorder Range("B10", "B" & r) ApplyBorder Range("C10", "C&qu...

Switching X Y axis in PP 2007
How do make the vertical axis the horizonal one and vice versa? -- etf Does Switch Row/Column on the Chart Tools Design tab do what you want? -- Echo [MS PPT MVP] http://www.echosvoice.com What's new in PPT 2010? http://www.echosvoice.com/2010.htm Fixing PowerPoint Annoyances http://tinyurl.com/36grcd PowerPoint 2007 Complete Makeover Kit http://tinyurl.com/32a7nx "etf" <etf@discussions.microsoft.com> wrote in message news:28669E0E-1FF7-47CB-9ED2-1769248A651E@microsoft.com... > How do make the vertical axis the horizonal one and vice versa? > -...

how do I delete documents from the start list in word and excel?
how do I delete documents from the start list in word and excel? You can not clear it whenever you want. You can however set the no of file names to be displayed to 0 which clears the list... In Excel 2003 Tool->Options->General Enter 0 against 'Recently Used File List' of clear the check box. Click 'OK' Word has a similar option. For 2007 versions or if you want to play with Registry Settings (not advised unless you understand it well) see http://www.mydigitallife.info/2008/01/13/how-to-clear-and-delete-recent-documents-list-in-office-2007-word-excel-p...

Newbee needs help Combo Box access 2007
I have a access 2000 project that would all me to create a combo box the added the following code , so the values from the combo box would be stored in the current form . also when typing the code below access 2000 would bring up the code string example when typing me.s it would bring up the value "shipper" from the field list is this feature gone or just turned off on my copy Example of code From Access 2000 Private Sub Combo 40_AfterUpdate(cancel As Integer) me.shipper = me.combo40.Column(0) me.Address = me.combo40.Column(1) error This error occurs whe...

Error saving Excel files in a network drive
I have a problem saving Excel files onto a network drive. I get an error saying it was imposible to save the file. It creates a temporary file and then I have to open it and save it as a new document. This issue doesn�t occur saving the file in my hard disk. This happens with "Full control" access to the shared folder... I have Windows XP and Office 2000. Thanks in advance Mateo. Hi Mateo, > I have a problem saving Excel files onto a network drive. I get an error > saying it was imposible to save the file. It creates a temporary file and > then I have to open it and sav...