Hey guys,
I have this Macro which i wrote for work; i read about the first 60 pages of a vba for dummies book and after that i started googling like a maniac and combining pieces of code to make it do what i need it to do. It works, and im sure there are more efficient ways to go about doing this.
Currently I'm using several Subs to maintain some sort of flow with the script.
- Sub repeatQue() will ask the user to define how many reccords they wish to create; it will then setup the necessary global variables accordingly. And call on the next Sub
- Sub startUpM() will count the amount of rows it needs to calculate a price for (the price generated fluctuates depending on prices generated by several formulas; most of them generated through cell formulas) once its done counting it will again set various variables as defined by several cell calculations.
- Sub fillListM() is where the price generation occurs and is dependent upon startUpM to know which row height it should be working on and where to get certain data. Once done it will update a row height variable and call upon the next sub called repeatM
- Sub repeatM() will check if the row height has reached its limit; if this is true it will call upon the sup endMacros or repeat the fillListM macro to calculate another line
- Sub endMacros() will publis, save and close an .scv file and will define whether the process needs to be repeated to create additional files depending on how many times a repeat process was asked for in the subRepeatQue. If it needs to repeat the process it will update a global variable and restart sub StartupM; If the global repeat variable repeats 0 the process will finally be ended.
To be honest im already really happy that I managed to get this far and its great to see it work. But when I set the repeat Variable to 30 , which would create 30 files I get an error message (actually I just tried it again with 30 so I could quote the error message just now and It worked) but I read somewhere that the error message can be caused by using and repeating too many subroutine loops. (I’m sorry as I can’t recreate the error I can’t give the exact error message.)
I’m basically wondering if I should be using something other than subroutines to do this.
This is my code, sorry about the mess.
Bookmarks