+ Reply to Thread
Results 1 to 11 of 11

populate cells in a matrix from goal seek values based on

  1. #1
    Registered User
    Join Date
    08-05-2009
    Location
    ny,ny
    MS-Off Ver
    Excel 2003
    Posts
    23

    populate cells in a matrix from goal seek values based on

    Novice user: wish to write an VB macro in Excel (2003) that populates a 6 row by 10 column matrix (for a 3 D graph) by inserting values from matrix row column headers in cells in another worksheet and using goal seek to derive a value which will be pasted in the respective cell in the 6X10 matrix

    Specific example: Matrix (Row Headers A2 to A7, Column Headers B1 to K1, Cell values are in B2 to K7). Please note row and column headers are numerical values since this is for a 3D graph

    Macro to be written

    Pick a value (numerical) from row header A3 in Sheet A and paste it in cell B6 in another sheet (Sheet B). Pick anothet value (numerical) from column header D1 in Sheet A and paste it in cell B7 in Sheet B.

    Run a goal seek scenario such that cell S10 in sheet B is equal to 50 by changing cell G8 in Sheet B

    Copy the value chosen/optimised by Goal Seek from cell G8 in Sheet B and paste it in Cell D3 (which is the relevant cell for the values for intersection of headers A3 and D1) in Sheet A

    Macro should populate all cells in the matrix in Sheet A (matrix cells to be populated are B2 to K7) in a similar fashion

    The macro should be locked in to the cells which are either being copied from or pasted into so that it still references them even if new columns or rows are inserted.

    Any help appreciated – please indicate exactly where I need to place any macro codes and in what editors

    Thanks
    Last edited by W2009; 08-06-2009 at 06:08 AM. Reason: Clarification

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    re: Goal Seek Scenarios /Pasting Results

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution. Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.
    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    Last edited by royUK; 08-06-2009 at 09:05 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    08-05-2009
    Location
    ny,ny
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: How do you write a macro to populate cells in a matrix from goal seek values base

    bump no response

  4. #4
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: How do you write a macro to populate cells in a matrix from goal seek values base

    Hi
    What is the formula used in goal seek?
    ravi

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How do you write a macro to populate cells in a matrix from goal seek values base

    Please edit the thread title and remove the unnecessary wording

    ravishankar, can i remond you thatthe forum Rules ask members not to answer questions that require amending according to a moderator's request.

  6. #6
    Registered User
    Join Date
    08-05-2009
    Location
    ny,ny
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: populate cells in a matrix from goal seek values based on

    Ravishankar Thanks for getting back
    Formula is
    Range("S10").GoalSeek Goal:=50, ChangingCell:=Range("G8")

    Please note that at the moment all cells are in one sheet but my objective is to keep the matrix and graph in a different sheet from the underlying model/calculations. In your answer please provide step by step instructions: I am a novice - Thanks

    RoyUK

    Thanks for getting back I thought my revised post had done what you had requested in your first post – please suggest what words I could remove - Thanks

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: populate cells in a matrix from goal seek values based on

    Thread titles should not contain unnecessary words such as help, How do I etc. I have edited this title twice now. Please don't change it again

  8. #8
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: populate cells in a matrix from goal seek values based on

    Hi
    I need to know the relation between the matrix, G8 & S10. S10 would probably have a formula A3*1.8+B2*2.5+3 or whatever
    Ravi

  9. #9
    Registered User
    Join Date
    08-05-2009
    Location
    ny,ny
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: populate cells in a matrix from goal seek values based on

    Hi Ravi

    Unfortunately it is an indirect relationship

    S10 = H15 - H17

    H15 =H7+H8-H11-H12

    H17 is a constant value

    H8 and H12 are directly linked to G8,
    (H8 = 200*(1+adj1)*G8 and H12= 150*(1+adj2)*G8)

    (H7 = 200*(1+adj1)*G7) and (H11 = 150*(1+adj2)*G7)

    H7 and H11 are linked to G8 indirectly through the effect of any change in G8 on G7 (G7= 100-G8),


    The values for adj1 (e.g. 4%) and adj2 (e.g. 2%) will come from the 10 column header and 6 row header of the graph matrix respectively and the objective is to place the new value for S10 (derived from goal seek i.e. set s10 = 50 by changing G8) in the matrix.

    So if adj1 (e.g. 4%) and adj2 (e.g. 2%) were picked from cell K1 and A4 respectively, the new value (from goal seek) of G8 will be placed in K4. The rest of the cells in the matrix should be populated in this fashion

    Hope this is clear

    Thanks again

  10. #10
    Registered User
    Join Date
    08-05-2009
    Location
    ny,ny
    MS-Off Ver
    Excel 2003
    Posts
    23

    Re: populate cells in a matrix from goal seek values based on

    Excel File example attached
    Attached Files Attached Files

  11. #11
    Forum Contributor
    Join Date
    02-27-2008
    Posts
    764

    Re: populate cells in a matrix from goal seek values based on

    Hi
    Try the macro in the attached file
    Ravi
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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