+ Reply to Thread
Results 1 to 7 of 7

Macro that AUTOMATICALLY activates another macro without human interference?

  1. #1
    Registered User
    Join Date
    02-24-2016
    Location
    Oslo
    MS-Off Ver
    Office 365
    Posts
    59

    Macro that AUTOMATICALLY activates another macro without human interference?

    I recently posted a thread with the same name. The reason why I'm using the same name again, is because I didn't know how to "UNSOLVE" the other thread. Well enough about that.

    For you that remembers my last thread, I needed to create a macro that opened a internet site, inserted username and password and extracted the stockprices from my portefolio.
    Further I needed the macro to automatically get the stock prices each night at 23.59 without doing anything. It does the job, but now I've encountered a new problem.

    I use static references which means that the macro is "screwed up" everytime I buy or sell a stock, so I tried to use the loop formula, but I can't get it to work. Is there another way to solve this problem or am I using the loop formula in a wrong way? Thank You very much for all responses.

    As you can see from the code below I dim 5 variables (which means I can only have 5 stocks in my portfolio before I have to write more code). I figured it should be a way to loop between the "tr's" and get the right values no matter how many stocks I buy or sell.

    Please Login or Register  to view this content.
    Best regards
    Thomas

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro that AUTOMATICALLY activates another macro without human interference?

    Why don't you use an array?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-24-2016
    Location
    Oslo
    MS-Off Ver
    Office 365
    Posts
    59

    Re: Macro that AUTOMATICALLY activates another macro without human interference?

    Well, I should probably have mentioned that I am quite new to vba, so that might be one of the reasons. If you have a suggestion (and preferably a detailed example) I would love to see it and try to implement it.

    Thank you I'm advance.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro that AUTOMATICALLY activates another macro without human interference?

    Do you know how many stocks are in your portfolio?

    Does each stock have a value/price in a table on the page?

  5. #5
    Registered User
    Join Date
    02-24-2016
    Location
    Oslo
    MS-Off Ver
    Office 365
    Posts
    59

    Re: Macro that AUTOMATICALLY activates another macro without human interference?

    Yes, that's correct. The stocks are ranked in "column A" by alphabetic order, while the price, number of stocks, total value etc is in the according row. So, I guess you can say it's in a table.

    At the moment I have 4 stocks!

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Macro that AUTOMATICALLY activates another macro without human interference?

    Are the values you want always in the HTML elements with the names tr1, tr2, tr3 etc?

    Do you always want to put the values in Q5, Q6, Q7 etc?

    If that's the case and you know the no of stocks you have you could use a loop.
    Please Login or Register  to view this content.
    If you don't always know the no of stocks something might be able to be done using the no of rows in the table.

    Something like this perhaps, though I'm kind of taking a bit of a guess with the code to get the no of rows in the table
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    02-24-2016
    Location
    Oslo
    MS-Off Ver
    Office 365
    Posts
    59

    Re: Macro that AUTOMATICALLY activates another macro without human interference?

    Yes, its the latter option. I want the macro to detect how many stocks I have every time I run the macro, so the number of stocks is "unknown".

    I tried to implement you solution, but I keep getting the errormessage: "Run-time error '438': Object doesn't support this property or method".

    Maybe I'm doing it wrong?

    Please Login or Register  to view this content.

+ 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 that AUTOMATICALLY activates another macro without human interference? HELP
    By Mangorni in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-24-2016, 09:23 AM
  2. Replies: 1
    Last Post: 10-10-2015, 01:00 AM
  3. Help with running a Macro that activates a different workbook whose name changes
    By jjcarter1988 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-24-2013, 05:45 PM
  4. Button who activates a macro
    By RoMarius1981 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-20-2012, 07:27 AM
  5. Cell select activates macro
    By pauluk in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-28-2005, 09:55 AM
  6. [SOLVED] How can I stop a macro for Human Interaction
    By Henry Stock in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-19-2005, 07:06 PM
  7. [SOLVED] Rectangle that activates a macro
    By in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-07-2005, 03:06 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