我是VBA的新手,不知道我的功能是否被正确使用,或者功能本身是否有缺陷。
我的子过程如下:
Sub InsertEquitiesBonds()
Dim ws As Worksheet, i As Integer
Set ws = Worksheets("PnL")
ws.Range("B3").Value = "Equities"
Worksheets("SummaryEquities").Range("MarketsEquities").Copy ws.Range("C4")
Dim LastUsedCell As Range
Set LastUsedCell = ws.Cells(ws.Rows.Count, "C").End(xlUp)
LastUsedCell.Offset(1, -1).Value = "Bonds"
Worksheets("SummaryBonds").Range("MarketsBonds").Copy LastUsedCell.Offset(2, 0)
For i = 4 To ws.Range("C" & Rows.Count).End(xlUp).Row
ws.Cells(i, 4).Value = OurFees(Range("C" & i))
Next i
Range("A1").Select
End Sub
如InsertEquitiesBonds()
中所述,代码一直有效,直到我不得不使用实际上只是忽略的功能OurFees
。这就引出了一个问题,我是不是正确地引用了我的函数,或者如果我是我,函数是否不可避免地存在缺陷?
OurFees()
函数的描述如下:
Function OurFees(rng As Range)
If rng.Value.IsEmpty = True Then
OurFees = ""
Else
Dim BasisPoint, VolMin, VolDistr As Range
If Columns("B").Find("Bonds").Row < rng.Row Then
With Worksheets("CheatSheet_Bonds")
BasisPoint = Application.WorksheetFunction.Index(Range("A5:E6"), Application.WorksheetFunction.Match(rng, Range("C5:C6"), 0), 3)
VolMin = Application.WorksheetFunction.Index(Range("A5:E6"), Application.WorksheetFunction.Match(rng, Range("D5:D6"), 0), 4)
End With
With Worksheets("SummaryBonds")
VolDistr = Application.WorksheetFunction.Index(Range("B12:C50"), Application.WorksheetFunction.Match(rng, Range("B12:B50"), 0), 2)
OurFees = Application.WorksheetFunction.Max(Range("D9") * BasisPoint, VolMin) * Range("D8") * VolDistr
End With
Else
With Worksheets("CheatSheet_Equities")
BasisPoint = Application.WorksheetFunction.Index(Range("A4:D21"), Application.WorksheetFunction.Match(rng, Range("B4:B21"), 0), 3)
VolMin = Application.WorksheetFunction.Index(Range("A4:D21"), Application.WorksheetFunction.Match(rng, Range("B4:B21"), 0), 4)
End With
With Worksheets("SummaryEquities")
VolDistr = Application.WorksheetFunction.Index(Range("B12:C40"), Application.WorksheetFunction.Match(rng, Range("B12:B40"), 0), 2)
OurFees = Application.WorksheetFunction.Max(Range("D9") * BasisPoint, VolMin) * Range("D8") * VolDistr
End With
End If
End If
End Function
答案 0 :(得分:1)
尝试以下
{
"repository": {},
"license": "MIT",
"scripts": {
"deploy": "brunch build --production",
"watch": "brunch watch --stdin"
},
"dependencies": {
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html"
},
"devDependencies": {
"babel-brunch": "6.1.1",
"brunch": "2.10.9",
"clean-css-brunch": "2.10.0",
"uglify-js-brunch": "2.10.0"
}
}