Results 1 to 14 of 14

Macro that AUTOMATICALLY activates another macro without human interference? HELP

Threaded View

  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? HELP

    Hi Guys.

    I've been creating a macro for my (small) investment team, but I'm struggeling to get the final touch to work. The macro just updates certain cells which contains a function that get (almost) real-time quotes from Yahoo finance. When the cells is updated the macro prints the total portfolio value to another sheet along with date and time. Simple as that. The problem is that some of my stocks is bought in another stock exchange which closes at another time of the day. In other words, I have to create a macro that automatically activates the above-mentioned macro at a certain time of the day (23.59). I've tried alot and my macro ONLY works if i press F5 before i leave work, but I want this update to happend every night without me interfering each day. Below you can se all the codes (ps. if you have any tips to make it better I would appriciate it).

    Sub knappen()
        Workbooks("Valuation (test)").Activate
        Sheets("MLC").Select
        Range("CADNOK").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""CADNOK=x"")"
        Range("USDNO").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""USDNOK=x"")"
        Range("SEKNOK").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""SEKNOK=x"")"
        Range("Axactor").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""axa.ol"")"
        Range("Bakkafrost").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""bakka.ol"")"
        Range("DNO").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""dno.ol"")"
        Range("Golden").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""gogl.ol"")"
        Range("GoldenReg").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""gogl-r.ol"")"
        Range("Kinross").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""k.to"")"
        Range("Nel").Select
        ActiveCell.FormulaR1C1 = "=StockQuote(""nel.ol"")"
    End Sub
    Dim req_value As Variant
    Private Sub Worksheet_Activate()
    req_value = [Markedsverdi]
    End Sub
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim X As Integer
          If [Markedsverdi] <> req_value Then
            With Worksheets("Avkastning")
                lastRow = .Range("A1048576").End(xlUp).Row
                For X = 1 To lastRow
                    If IsDate(.Range("A" & X).Value) Then
                        If CDate(.Range("A" & X).Value) = Date Then Exit For
                    End If
                Next
                .Range("B" & X).Value = Range("Markedsverdi").Value
                .Range("A" & X).Value = Date
                .Range("D" & X).Value = Time
            End With
        End If
    End Sub
    
    Private Sub Workbook_Open()
    If Weekday(Now, vbMonday) < 6 Then
        Application.OnTime VBA.TimeValue("23:59:00"), "knappen"
    End If
    End Sub

    I have never written a macro before, so the macro above is creatied through googling and trying/failing.

    Best regards
    Thomas Mangor-Jensen
    Last edited by Mangorni; 04-29-2016 at 05:39 AM. Reason: Tips from another forum user.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 10-10-2015, 01:00 AM
  2. [SOLVED] Macro activates in wrong sheet
    By SoothSailor in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-08-2015, 12:17 PM
  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. 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