+ Reply to Thread
Results 1 to 22 of 22

Run a simple goalseek macro in every sheet except a few

  1. #1
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Run a simple goalseek macro in every sheet except a few

    Hi There,
    I have tried to use answers from previous posts on this subject but nothing works unfortunately. I just want to run a very simple goalseek macro in every sheet except some specific sheets when I use the shortcut (ctrl b in this case)

    My macro is currently this:

    Sub balance ()

    Range ("U61") .Goalseek Goal :=0, Changingcell:=Range ("e25")
    Range ("z56") .Goalseek Goal :=0, Changingcell:=Range ("z59")

    End Sub


    I want to run this macro on all sheets in my spreadsheet except ones with the following names:

    Loadcombs required
    Inputs & Weight Distribution
    Long Summary
    Tran Summary
    Trans Rollout

    Everything I have tried so far either only runs on the selected sheet or tries to run on all of them and bugs in those 5.

    Please help!!

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Run a simple goalseek macro in every sheet except a few

    Please Login or Register  to view this content.

    Now....if you're in Southampton doing VBA based reporting then you're either working for Carnival or B&Q. Which is it?

  3. #3
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Run a simple goalseek macro in every sheet except a few

    @bellygas, beat me to the punch. my stab at it:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    Many thanks for your swift reply!

    I actually work for a Civil Engineering company nearby - the spreadsheet concerns structural design of a marine structure!

    I have obviously messed something up as when I copied your solution between Sub balance () and end sub, it says I have a compile error: syntax error when I try to run it... I am very new to macros and coding in general so treat me as a total moron!

  5. #5
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Run a simple goalseek macro in every sheet except a few

    No worries. copy and paste your whole macro.....but put [ code ] tags around it

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    Many thanks to you as well dmcgov!

    When I run your suggestion I get a run time error '28' - out of stack space. Is this something to do with lack of memory or too many sheets?

  7. #7
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Run a simple goalseek macro in every sheet except a few

    https://docs.microsoft.com/en-us/off...space-error-28



    And you need to put [ code ] at the start (without the spaces) and [ /code ] at the end. And when I say the whole macro, I mean all of it with the extra stuff you've just added.

  9. #9
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    Please Login or Register  to view this content.
    Last edited by ChrisGeorge89; 01-22-2019 at 11:45 AM.

  10. #10
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    Those are the 2 I tried

  12. #12
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Run a simple goalseek macro in every sheet except a few

    @ChrisGeorge89 there could be 3 issues with the error.
    1) you have an old (and not updated) excel.
    2) you have too many programs open on the taskbar
    3) your windows installation may need to be updated.

    let me know if that helps.

  13. #13
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Run a simple goalseek macro in every sheet except a few

    One more question. When you get the syntax error, which line is highlighted?

  14. #14
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    It highlights the text in line Range ("u61") etc. and then the Sub balance turns yellow afterwards ( I hope that makes sense)

  15. #15
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Run a simple goalseek macro in every sheet except a few

    try this:

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few


  17. #17
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    Unfortunately I am still getting the syntax error on that one as shown (without error box) above

  18. #18
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    @dmcgov - on your original suggestion should that be as a seperate macro to the one called balance? As it never actually says anything about the goalseek, it only 'calls' balance

  19. #19
    Valued Forum Contributor
    Join Date
    03-24-2014
    Location
    England
    MS-Off Ver
    Excel 2003 - 2016
    Posts
    575

    Re: Run a simple goalseek macro in every sheet except a few

    Take the spaces out.

    ie, instead of
    Please Login or Register  to view this content.
    put

    Please Login or Register  to view this content.

  20. #20
    Registered User
    Join Date
    01-22-2019
    Location
    Southampton, England
    MS-Off Ver
    Microsoft Office 365
    Posts
    12

    Re: Run a simple goalseek macro in every sheet except a few

    It works!!

    Thank you both so much for your patience and your help!!

  21. #21
    Registered User
    Join Date
    08-20-2018
    Location
    New york
    MS-Off Ver
    2016
    Posts
    21

    Re: Run a simple goalseek macro in every sheet except a few

    Hi All,

    I am having a similar challenge to ChrisGeorge89.

    After putting in the code:
    Please Login or Register  to view this content.
    It appears to work except the sheet labeled TaxLots is not skipped over and I cannot figure out why.

    Also, I have this as a VBA code so how would I make it so that it has a hotkey and only activates when the hotkey is pressed?

    Thanks in advance for any help!

    P.S.
    New to forum
    Relatively new to VBA and macros
    Is it preferred I start a new thread for this?
    Last edited by Goakseeker; 02-11-2019 at 02:21 PM.

  22. #22
    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: Run a simple goalseek macro in every sheet except a few

    Maybe the sheet name is "Tax Lots", not "TaxLots"
    Entia non sunt multiplicanda sine necessitate

+ 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. Automate Goalseek using macro and vba
    By fidu_k in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-21-2018, 10:22 AM
  2. [SOLVED] Automate goalseek so that it runs when any cell on the sheet is changed
    By Goakseeker in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 08-21-2018, 04:56 PM
  3. Stop goalseek macro if value is ecxceeded
    By 95marine in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2017, 05:15 PM
  4. Macro to peform Goalseek across range of columns
    By Matt_86 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2014, 11:06 AM
  5. [SOLVED] Simple macro to create list of sheet names and the contents of cells A1 & N1 of each sheet
    By atcsmh in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-15-2013, 11:11 AM
  6. goalseek macro rounds to two decimals. need 3!
    By thesweetp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-30-2011, 02:34 PM
  7. basic excel macro (goalseek)
    By athmea in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 04-03-2008, 09:59 AM

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