• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to do iteration calculation using VBA in Excel

OSK

New Member
I am making a model of Electric vehicle load on electric grid. I was using formulas to calculates things but now what i need to do will not be possible with formulas. I have not worked with VBA before so have no idea how to do it. if someone can help, it will be great. I have attached a part of workbook not to make it complicated.
The code will use IF statement with multiple conditions and check if voltage drop is more than 0.5% (marked red) OR current if it is less than 0.06 (marked red). if anyone of the condition is true it will decrease the charging load of the car by 1kW e.g. from 11 to 10. This code will look every row and keep decreasing the load until both conditions are false. now as we decrease the charging load, the car will take longer to charge, so the more time cells will have load. numbers of cells for every load is calculated in the workbook, which can be used. when the load reaches 12 am it should also rotate and start from the top i.e 12:15 am. the results are printed in the output table as the input tables are calculated by formulas and cannot be disturbed.
Maybe its not hard but i dont have VBA knowledge to perform this task.
 

Attachments

  • example Iteration.xlsx
    19.4 KB · Views: 3
Last edited:
OSK
Questions...
Voltage drops: You wrote 'is more than 5% (marked red)' BUT
You've marked 'is more than 0,5%' ... any challenges?
as well with
Current: is less than 0.6 (marked red) BUT
You've marked ' is less than 0.06' ... any challenges?

Is Your 'Car Load'-table filled as 'wanted result'?
 
@vletm 5% is the value from my original model, as i cant paste all the values here because of the size so i just took 0.5% as an example.
with current, it was a mistake. i should have written 0.06.
car load table is not the output. output tables are below. If current OR voltage value is above the limit the car load will be reduced by 1 kw and those values will be printed in the tables below
 
OSK
5% ... so there are no any real marked values ...
0.6 ... as well ... there are none real marked values ...
It would be more clear even for You
if You would show correct values and red marks
or
there should be somewhere place which would has those 'limit'-values.
'Outputs' would have 'wanted results' too
then no need to start to make guesses.
 
Back
Top