+ Reply to Thread
Results 1 to 4 of 4

VBA code is working, but struggling to store the output

  1. #1
    Registered User
    Join Date
    04-28-2013
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    93

    VBA code is working, but struggling to store the output

    Dear Forum Members,

    I am in a situation where I managed to do the tricky part but am stuck with the easier stuff (or at least I think it's easier). I compiled the following VBA code which I use for some computations:

    Please Login or Register  to view this content.
    After the "Loop Until" row and before the Next rows I want to store the output from that particular solution, namely I want to save the outcome for cells (16,2), (16,3), (17,2), (17,3) and (31, 3). Then, after all the calculations are completed I want to write those solutions somewhere in the same sheet (say in columns M, N, O, P and Q). I've tried different things, but they only seem to invalidate my code without actually storing and writing the output. Any suggestions?

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: VBA code is working, but struggling to store the output

    This writes the values to the next empty row in columns M,N,O,P,Q.
    Is that what you want?

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    04-28-2013
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: VBA code is working, but struggling to store the output

    Thank you for the reply, AlphaFrog. While this code does the job, I was expecting an output that consists only of 3 results. Your code gives me 81 results. There are three different starting values for my cells B16:C17. These are 20,20,40,40; 30,30,60,60 and 40,40,80,80. For each of these three starting values Solver is supposed to run until it finds some ultimate solution (one and only one per starting value). The three solutions that I am looking for are within those 81 results (I found my 3 solutions one by one before composing the Macro with the For loops). I'm just wondering what are the other 78 out of 81 results that I am getting.

  4. #4
    Registered User
    Join Date
    04-28-2013
    Location
    Stockholm
    MS-Off Ver
    Excel 2007
    Posts
    93

    Re: VBA code is working, but struggling to store the output

    Now, when I think about it, you are absolutely right! I did not realize that I am finding 81 unique solutions to my problem since I have 4 For Loops with three steps each, and 3^4 = 81. Many thanks for your help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Struggling to get a small search function working correctly
    By bodhi808 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-17-2013, 08:34 PM
  2. [SOLVED] Code For Button To Store Data
    By swordswinger710 in forum Excel Programming / VBA / Macros
    Replies: 42
    Last Post: 08-01-2012, 01:30 PM
  3. Output array to worksheet not working.....
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-14-2011, 10:23 AM
  4. Store variable values in macro code
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-04-2011, 05:35 AM
  5. [SOLVED] Store FilePath Inside Code
    By Magnivy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-16-2006, 05:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1