+ Reply to Thread
Results 1 to 12 of 12

Macro works except for one cell

  1. #1
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Macro works except for one cell

    Attached workbook

    I have a macro that works except for one cell (H24) which does not solve using Solver, the other 4 cells work fine. I have uploaded my Excel 2007 workbook. Any input/comments would be appreciated.

    I’m no expert but I not sure if some of the code is needed. I have taken some of the fluff out already. I was wondering if we could make a small change as well. Right now when a number is entered in any one of the five cells (below) and the enter key is pressed the macro starts and the answer is produced. I was wondering if we could set up one cell to be used as a manual start button, if you will, to start the macro for all 5 cells.

    I can post the code here if you like or please check my workbook.

    This is what the macro should be doing:

    1 - Search and determine which cells have numbers in the following cells: D24,F24,H24,J24,L24. There will always be numbers in 1 or all 5 cells.

    2. For each found cell with a number the program does a calculation using Solver and then enters the answer in the cell below it. So as an example, for cell L24 (7.77 was entered) the answer (1.55) would be placed in cell L25.

    Thank-you for all your help.
    Attached Files Attached Files
    Last edited by CHRISTINEKENDALL93; 10-14-2018 at 05:05 PM. Reason: to attach workbook

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,944

    Re: Macro works except for one cell

    to attach a file.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Macro works except for one cell

    I need to delete the current workbook and upload the correct one could you assist.

    Thanks
    Last edited by CHRISTINEKENDALL93; 10-14-2018 at 05:36 PM.

  4. #4
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Macro works except for one cell

    Here is the correct worksheet.
    Thanks
    Attached Files Attached Files

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro works except for one cell

    There are no macros in an xlsx file, Christine.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Macro works except for one cell

    Not a great start to posting! Attached is the correct workbook with the macros.
    So sorry about that.
    Attached Files Attached Files

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro works except for one cell

    Christine, that looks like very convoluted code to so something that should be simple. Can you explain?

    If you set a reference to Solver, your code can be simplified:

    Please Login or Register  to view this content.
    ... except I don't understand the red part. You are setting B23 to Min while constraining B23 to ... what?

  8. #8
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Macro works except for one cell

    Hi

    Thanks for your help. This is what the macro should be doing:

    1 - Search and determine which cells have numbers in the following cells: D24,F24,H24,J24,L24. There will always be numbers in 1 or all 5 cells.

    2. For each found cell with a number the program does a calculation using Solver and then enters the answer in the cell below it. So as an example, for cell L24 (7.77 was entered) the answer (1.55) would be placed in cell L25.

    Solver – Set Target cell: $B$23
    Equal To: Min Value of: 0
    By changing cell $A$23
    Subject to the constraints $B$23 = $C$23

    Answer: 1.55

    Hope this answers your question, if not please let me know.

    Christine

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro works except for one cell

    This doesn't make sense to me:

    Solver – Set Target cell: $B$23
    Equal To: Min Value of: 0
    By changing cell $A$23
    Subject to the constraints $B$23 = $C$23
    You can set a cell to a given value or a minimum -- not both.

    I don't grok what you're trying to calculate.

  10. #10
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Macro works except for one cell

    I'm not an expert at this stuff so you have to bear with me. I have using Solver for years, I didn't set it up but that what I need. Have you checked the cells that do work on my sheet to see what happening? It's cell H24 that I'm having trouble with. That would explain better than I can. Thanks again.

    Solver – Set Target cell: $B$23
    Equal To: Min Value of: 0
    By changing cell $A$23
    Subject to the constraints $B$23 = $C$23

  11. #11
    Registered User
    Join Date
    10-14-2018
    Location
    Brampton, ontario
    MS-Off Ver
    2007
    Posts
    74

    Re: Macro works except for one cell

    Hi shg

    I just wanted to let you know that we solved the problem and it's back working. Thank-you for all your help.

    Christine

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Macro works except for one cell

    Glad you got it sorted, sorry I was useless.

+ 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. Replies: 7
    Last Post: 07-17-2018, 09:59 AM
  2. FindNext works when called from macro in debug but not from a cell formula
    By bambi42 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-18-2016, 09:13 AM
  3. [SOLVED] Macro to word wrap text only works on one cell but i need it for multiple cells
    By Triscia in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-29-2016, 12:03 PM
  4. Macro that works over multiple cells when the cell is clicked on
    By surya316 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-26-2015, 08:05 PM
  5. [SOLVED] Macro to Move Multiple Objects based on Cell Values (NFL Schedule) only works sometimes
    By edneal2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2013, 01:49 AM
  6. [SOLVED] how to set a macro that only works when the active cell is on a certain column?
    By kjy1989 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-11-2013, 02:06 AM
  7. Replies: 11
    Last Post: 08-31-2010, 01:30 PM

Tags for this Thread

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