+ Reply to Thread
Results 1 to 25 of 25

how to fix a macro

  1. #1
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    how to fix a macro

    Hello everyone,

    I'm very aware this is not a great time to ask for help, but if anyone if feeling charitable and has some free time on this blessed day, I'm in need of some help from a smarter person than me!

    I have made this code, and I need to know if the syntax is bad, or if I'm justifying to do something I can't do:

    Please Login or Register  to view this content.
    Last edited by candicee; 12-24-2017 at 06:43 PM.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,434

    Re: how to fix a macro

    You seem to be mixing up Cells syntax and Range syntax. You refer to a cell by Cells(row, column) or by Range(" columm and row "), for example, Range("A2").
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    ok ill look into that thank you!

    do you think this could work if I fixed the cells and range syntax?

  4. #4
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    Is this what you mean?
    it still won't work

    Please Login or Register  to view this content.
    Last edited by candicee; 12-24-2017 at 06:21 PM.

  5. #5
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: how to fix a macro

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  6. #6
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: how to fix a macro

    Nevermind
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  7. #7
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    Thank you for the remark, I used the code tags!

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,434

    Re: how to fix a macro

    This
    Please Login or Register  to view this content.
    should be this
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    thank you!

    I changed it. There is still a problem with this line:
    Please Login or Register  to view this content.
    I thought it might be the "ligne -1", but I tried without and it still won't work.

  10. #10
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: how to fix a macro

    Please Login or Register  to view this content.

  11. #11
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,525

    Re: how to fix a macro

    Do I read it right? 30600 loops? Seems a little high, even for the holiday season.

    How did you arrive at 10192?
    I think you could replace this
    Please Login or Register  to view this content.
    with this
    Please Login or Register  to view this content.
    Should be faster.
    I have not checked it, going out the door momentarely, so be careful.
    Last edited by jolivanes; 12-24-2017 at 07:29 PM.

  12. #12
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    Do you mean that I did something wrong? I'm supposed to get a performance out of an index (Euro Stoxx) for a period of more than 20 years (day by day), hence the number of loop.
    Do you think it can't work? excel has been crashing if I try to execute the macro but I thought it meant I typed something wrong!

  13. #13
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: how to fix a macro

    See whether this runs:

    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    thank you.

    I tried and I get an error message and it highlights this line:
    Please Login or Register  to view this content.

  15. #15
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: how to fix a macro

    Oops!

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    xladept, thank you

    EDIT: it works great!

    only problem is the variables pa pae and mdd should come out as percentages, and so I have weird answers in my message box but I will try to fix that now!
    Last edited by candicee; 12-24-2017 at 08:10 PM.

  17. #17
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: how to fix a macro

    You're welcome!

    Maybe:

    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    thanks, the problem is I would need to make a similar change to switching a cell in excel from "general" to "percentage", so that it changes the result as well, for example from 1 to 100%.


    I have another question, would I be able to change that program so that a user can select one out of 5 index, and it shows the results of those things (performance, max drawdown..) only for the one they chose?

    Like an input box that gives a result depending on what the user type in?

  19. #19
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: how to fix a macro

    What do those values look like now?

    I can't visualize the other question.

  20. #20
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    Basically I built this program around two columns: the dates and the values at each date of one index. In my original file I have 4 other column with the values by dates of 4 other indexes.

    Originally, I planned to create a button activated macro for each index, (the program you helped me built).

    But now I think I'd be better to have only one button that would bring up an input box that asks "enter the name of your index", and depending on what index the user typed in, the program would execute the calculations for the column pertaining to that index.

    something like:
    n=inputbox ("Choose one of the following index: EuroStoxx, CAC40.. etc")

    if n = eurostoxx then
    and here Ienter the program using the corresponding column
    end if
    if n = cac40 ... and so on and so on

  21. #21
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    For performance it shows 0,0037
    for yearly performance it shows 0,9963811,
    for maximum drawdown it shows -0,1767426

    When I have done these calculations with excel only, the results were
    226,40%
    4,27%
    -66,88%

    so there are several mistakes along the way, but I think the format is one of them

  22. #22
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: how to fix a macro

    Thanks for the rep candicee - I'll delve into it further tomorrow!

  23. #23
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: how to fix a macro

    Hi Candicee,

    I believe that I need a sample workbook so will you?:

    Attach a sample workbook. Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  24. #24
    Registered User
    Join Date
    12-24-2017
    Location
    strasbourg, France
    MS-Off Ver
    15.41 excel
    Posts
    21

    Re: how to fix a macro

    I tried a couple time, and it won't upload my file! thanks anyways

  25. #25
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: how to fix a macro

    Don't post the whole book - just a hundred or so rows

+ 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] Macro to add another Macro to a button to add into a larger Macro.
    By taylorsm in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-03-2016, 10:51 AM
  2. [SOLVED] Define variable in macro than calling that macro inside another macro
    By jakopak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2015, 10:58 AM
  3. Using a macro on workbook1 to create a button in wb2 and assigning macro "wb2!macro"
    By penfold1992 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-13-2014, 11:39 AM
  4. [SOLVED] Macro to show Which macro didnt work in a nested macro
    By akhileshgs in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 03:21 AM
  5. Perform macro "on open" specific file- store macro in Personal Macro Workbook?
    By thompssc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-17-2012, 12:38 PM
  6. lookup macro, solver macro, realtime macro
    By xelhelp in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-02-2011, 06:14 PM
  7. Cannot find macro error when running a macro from a macro in a diffrent workbook.
    By Acrobatic82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2010, 09:22 AM

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