J
jsuden
When I run the following code, I get the error "For loop not
initialized". Im having problems iwth the code enclosed by asterisks.
What im trying to do is to make the weight for each fund below row 79
go from 0% to 5% then back to 0% before moving on to the next fund (the
font for these funds below row 79 is red. When the fund is at a 5%
weight, I want to see waht strategy it is (which will be in column B)
and find all the funds above row 80 that match that strategy and
perform a calculation on those funds.
the spreadsheet looks something like this
Column A Column B Column D
Column E
Row 1 Fund A 3.20% Conv
Arb
Row 2 Fund B 6.20% Conv
Arb
Row 79 Fund C 4.10% Equity
LS
Row 80 Short list A Conv Arb 5%
Row 81 Short list B Equity LS 0%
So In this case, SHort list A is at the 5% weight, and is a conv arb
fund. So I want to take the 3.2%/((9.4%)/(4.4%)) where 9.4% is the
3.2%+6.2% for the conv arb funds and 4.4% is the 9.4%-5%
Dim CellW As Range
Dim CellY As Range
Dim i As Integer
Number = CountRed(Worksheets("AG").Range("A1:A110"))
For i = 1 To Number
Application.Goto Sheets("AG").Range("A79") 'this needs to
reflect the cell above where the short list starts
ActiveCell.Offset(0 + i, 3).FormulaR1C1 = "5%"
For Each CellW In Worksheets("ag").Range("D479") ' the
ending cell needs to be the same as range above
**** If ActiveCell.Offset(0 + i, 3).Value = "5%" _
And ActiveCell.Offset(0 + i, 3).Font.ColorIndex = 3 _
And Range("E:E").Text = ActiveCell.Offset(0 + i, 1).Text
Then
CellW.Value = (Range("E:E").Offset(0, -1).Value /
((Application.Sum(Range("E:E")).Offset(0, -1)) /
(Application.Sum(Range("E:E")).Offset(0, -1)) - 0.05))****
Sheets("Summary").Range("D3").Offset(0 + i, 0).Value =
Sheets("Summary").Range("C4").Value
Sheets("Summary").Range("H3").Offset(0 + i, 0).Value =
Sheets("Summary").Range("G4").Value
Sheets("Summary").Range("P3").Offset(0 + i, 0).Value =
Sheets("Summary").Range("O4").Value
Sheets("Summary").Range("T3").Offset(0 + i, 0).Value =
Sheets("Summary").Range("S4").Value
Application.Goto Sheets("AG").Range("A79") 'this needs to
reflect the cell above where the short list starts
ActiveCell.Offset(0 + i, 3).Select
ActiveCell.FormulaR1C1 = "0%"
End If
Next CellW
Next i
End Sub
Any suggestions?
initialized". Im having problems iwth the code enclosed by asterisks.
What im trying to do is to make the weight for each fund below row 79
go from 0% to 5% then back to 0% before moving on to the next fund (the
font for these funds below row 79 is red. When the fund is at a 5%
weight, I want to see waht strategy it is (which will be in column B)
and find all the funds above row 80 that match that strategy and
perform a calculation on those funds.
the spreadsheet looks something like this
Column A Column B Column D
Column E
Row 1 Fund A 3.20% Conv
Arb
Row 2 Fund B 6.20% Conv
Arb
Row 79 Fund C 4.10% Equity
LS
Row 80 Short list A Conv Arb 5%
Row 81 Short list B Equity LS 0%
So In this case, SHort list A is at the 5% weight, and is a conv arb
fund. So I want to take the 3.2%/((9.4%)/(4.4%)) where 9.4% is the
3.2%+6.2% for the conv arb funds and 4.4% is the 9.4%-5%
Dim CellW As Range
Dim CellY As Range
Dim i As Integer
Number = CountRed(Worksheets("AG").Range("A1:A110"))
For i = 1 To Number
Application.Goto Sheets("AG").Range("A79") 'this needs to
reflect the cell above where the short list starts
ActiveCell.Offset(0 + i, 3).FormulaR1C1 = "5%"
For Each CellW In Worksheets("ag").Range("D479") ' the
ending cell needs to be the same as range above
**** If ActiveCell.Offset(0 + i, 3).Value = "5%" _
And ActiveCell.Offset(0 + i, 3).Font.ColorIndex = 3 _
And Range("E:E").Text = ActiveCell.Offset(0 + i, 1).Text
Then
CellW.Value = (Range("E:E").Offset(0, -1).Value /
((Application.Sum(Range("E:E")).Offset(0, -1)) /
(Application.Sum(Range("E:E")).Offset(0, -1)) - 0.05))****
Sheets("Summary").Range("D3").Offset(0 + i, 0).Value =
Sheets("Summary").Range("C4").Value
Sheets("Summary").Range("H3").Offset(0 + i, 0).Value =
Sheets("Summary").Range("G4").Value
Sheets("Summary").Range("P3").Offset(0 + i, 0).Value =
Sheets("Summary").Range("O4").Value
Sheets("Summary").Range("T3").Offset(0 + i, 0).Value =
Sheets("Summary").Range("S4").Value
Application.Goto Sheets("AG").Range("A79") 'this needs to
reflect the cell above where the short list starts
ActiveCell.Offset(0 + i, 3).Select
ActiveCell.FormulaR1C1 = "0%"
End If
Next CellW
Next i
End Sub
Any suggestions?