PDA

View Full Version : Need help with looping



pyro77
11-13-2008, 06:47 PM
Hey guys, I'm practically new to VBA and I've been asked to do some coding in it.

I've attached a zip file containing 2 excel files. The report_src file has the script in it. The first one called gendata is the one we're looking at. The other file, MOS_Demand_JUN is where we pull the data from.

Ok, so forget about how to pull the data. What I'm having trouble is pulling the data from different files. I managed to do a crude version of it. As you can see, it will take in the parameters from the cells in the report_src file and it will do the calculations and create new worksheets in that file while pulling data from MOS_Demand_Jun etc. There will be others of course, MOS_Demand_May for example.

So what I'm having problems with here is what if I need to do all 12 months and maybe 2 months only some other time? I made it for 5 months in that version. I want it to be dynamic, knowing when to stop pulling when there are no parameters to take in. So I'm guessing so sort of loop? You can duplicate the data file (mos_demand_jun) to may, july, aug etc. They need to be opened for it to pull the data. Just rename it to the first 3 letters of the month.

Please ask me if you need any clarifications.

Again, I'm totally new to vb script, so I'm hoping someone could help.

pyro77
11-14-2008, 12:47 AM
Ok, I managed to do a while loop that will see if the next column is empty, it will stop. Now the problem is how do I change the B column values to C and so on once it finishes looping it once?