Hello!
I have one sheet with "raw" stock price data and one sheet with the returns calculated from the raw price data.
I have managed to create a userform that inserts a new row to both of the sheets and pastes the new prices that the user inserts in the userform, however I have not succeeded in pasting the formula ((raw!A1-raw!A2)/raw!A2) for the returns in the "returns"sheet...
My code looks like this:
Private Sub cmdsend_Click()
Sheets("raw").Activate
Cells(1, 1).Activate
Selection.EntireRow.Insert Shift:=xlDown
Sheets("raw").Range("a1") = Me.txtboxmmm.Value
Sheets("raw").Range("b1") = Me.txtboxbg.Value
Sheets("raw").Range("c1") = Me.txtboxdis.Value
Sheets("returns").Activate
Cells(1, 1).Activate
Selection.EntireRow.Insert Shift:=xlDown
Sheets("returns").Range("a1") = (Sheets("raw").Range("A3") - Sheets("raw").Range("A4")) / Sheets("raw").Range("A4")
Sheets("returns").Range("b1") = (Sheets("raw").Range("b3") - Sheets("raw").Range("b4")) / Sheets("raw").Range("b4")
Sheets("returns").Range("c1") = (Sheets("raw").Range("c3") - Sheets("raw").Range("c4")) / Sheets("raw").Range("c4")
End Sub
I cant figure out how to get the formula right in the code.
Could someone please help me?
Thanks,
Cashmire
I have one sheet with "raw" stock price data and one sheet with the returns calculated from the raw price data.
I have managed to create a userform that inserts a new row to both of the sheets and pastes the new prices that the user inserts in the userform, however I have not succeeded in pasting the formula ((raw!A1-raw!A2)/raw!A2) for the returns in the "returns"sheet...
My code looks like this:
Private Sub cmdsend_Click()
Sheets("raw").Activate
Cells(1, 1).Activate
Selection.EntireRow.Insert Shift:=xlDown
Sheets("raw").Range("a1") = Me.txtboxmmm.Value
Sheets("raw").Range("b1") = Me.txtboxbg.Value
Sheets("raw").Range("c1") = Me.txtboxdis.Value
Sheets("returns").Activate
Cells(1, 1).Activate
Selection.EntireRow.Insert Shift:=xlDown
Sheets("returns").Range("a1") = (Sheets("raw").Range("A3") - Sheets("raw").Range("A4")) / Sheets("raw").Range("A4")
Sheets("returns").Range("b1") = (Sheets("raw").Range("b3") - Sheets("raw").Range("b4")) / Sheets("raw").Range("b4")
Sheets("returns").Range("c1") = (Sheets("raw").Range("c3") - Sheets("raw").Range("c4")) / Sheets("raw").Range("c4")
End Sub
I cant figure out how to get the formula right in the code.
Could someone please help me?
Thanks,
Cashmire