Results 1 to 12 of 12

Need help portfolio simulation

Threaded View

  1. #11
    Registered User
    Join Date
    06-09-2013
    Location
    poland
    MS-Off Ver
    Excel 2007
    Posts
    9

    Re: Need help portfolio simulation

    Sory but i don't know why your macro ruin my formula for example in C7 C8 C9, and why you use cell G37
    If i - cell.Row >= 20 Then
        Range("G37") = 20
    Else
        Range("G37") = i - cell.Row
    End If
    Macro can not use cell G37, Cell G37 is only change average. If Cell G37=20 then average for each stock is for 20 last day so that cell can not be changed. Maybe this way:

    1) Macro copy cell B39: to the end,
    2) next paste to G37
    3) Macro run solver
    4) result from J31 copy to the cell B39
    5) loop (cell B40, B41 etc) loop stop when meet empty cell.

    Sub Makro1()
    '
    ' Makro1 Makro
    '
    
    '
        Range("B39").Select
        Selection.Copy
        Range("G37").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
        SolverOk SetCell:="$C$20", MaxMinVal:=1, ValueOf:="0", ByChange:="$C$11:$AG$11"
        SolverSolve UserFinish:=True
        Range("J31").Select
        Selection.Copy
        Range("C39").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
            :=False, Transpose:=False
    End Sub
    Something like that but with loop. New file beacuse i added new row.

    I modifed your code
    Sub Makro1()
    i = Range("B" & Rows.Count).End(xlUp).Row
    
    For Each cell In Range("B39:B" & i)
    
    cell.Copy
    Range("G37").PasteSpecial Paste:=xlPasteValues
    
    
    SolverOk SetCell:="$C$20", MaxMinVal:=1, ValueOf:="0", ByChange:="$C$11:$AG$11"
    SolverSolve UserFinish:=True
    
    Range("J31").Copy
     cell.Offset(0, 1).PasteSpecial Paste:=xlPasteValues
     
    Next
    
    Application.CutCopyMode = False
    
    End Sub
    WORKS! BIG THANKS ALF. I am very very happy and appreciate your help and support big thanks again
    Attached Files Attached Files
    Last edited by pulkownik; 06-14-2013 at 04:33 PM.

Thread Information

Users Browsing this Thread

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

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