profit/loss calculator
The code is pretty simple. I just did the basics. If you need additional
help let me know. the variable "c" represent column A data. To get the
other columns use offset. See code below.
Sub updatebond()
'get code from your userform
ISINCODE = "abc"
Set c = Columns("A:A").Find(what:=ISINCODE, _
LookIn:=xlValues)
If c Is Nothing Then
LastRow = Range("A" & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
Range("A" & NewRow) = ISINCODE
Range("E" & NewRow) = CurrentPrice
Else
'code already in table. Calculate new Avarage Price
c.Offset(rowoffset:=0, columnoffset:=4) = AvaragePrice
End If
End Sub
"franky" wrote:
That didn“t come out right. I`ll try again. My columns are arranged as
follows:
A:
ISIN CODE
B:
AMOUNT
C:
VALUE
D:
CURRENT PRICE
E:
AVERAGE PRICE
F:
PROFIT / LOSS
|