-
IF, Solver and Clearing Cells based on the IF
In summary:- I have two options and two different solver inputs to run based on the options. I have got this working correctly.
- One of the solver options produces 100 loops, while the second will produce less (say, 50)
- The solver outputs are being graphed. If I use the first solver and then the second, I have data left over. This means my graph is using the 50 loops of my second solver option, and then the last 50 of the first solver options.
I have googled around trying various combinations of what I'm looking for. After searching I found a formula posted by someone of this site, the VBA is (similar to), however, I could not find anything else suitable:
[vba] Option Explicit
Sub ClearCell()
Range("B103:B104").Clear
End Sub[/vba]
My issues are that when I try to run the macro after implementing the above VBA is:
for "Option Explicit" - compile error: invalid inside procedure
If I remove it, VBA expects me to end the entire Sub I'm working on previous to opening this new one - i.e. the Sub I'm using for my entire macro
I'm relatively new to VBA and am not overly familiar with how Sub works, or what it actually does.
What I guess I'm really looking for is an answer as to whether or not it is possible to clear my 50 results before running the second conditional solving, or if I should implement a second button to clear the results for me (the easy way). It is preferred that it was all in the one click.
edit: I will have the macro clear all entries as solver sometimes returns no result. switching from one solver IF to another could produce anomalies in my graph.
I don't really want to post my VBA code to the public but can do upon PM request - this is for a University project and I don't particularly want someone else turning up with an identical VBA code
The gist of it goes like this:- sub starts,
- IF decision,
- loop starts - option one or option two,
- loop ends,
- sub ends
What I want to have:- sub starts,
- IF decision,
- excess data is cleared,
- loop starts - option one or option two,
- loop ends,
- sub ends
Any insight would be much appreciated
Last edited by zzane; 10-27-2009 at 05:52 PM.
-
I might also add something important that I seem to have missed out. I need the formulas to remain there but display nothing - otherwise solver has nothing to go by when using the loop. I am beginning to think it may be better to just include 100 loops for each IF and leave it at that :P
i.e. if it clears the formulas from the cells, the final 50 cells of the first IF option will appear 0 or blank due to solver not having anything to work with
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules