Sub 勝率計算() Range("N2").Select ActiveCell.FormulaR1C1 = "ヒット" Range("N3").Select ActiveCell.FormulaR1C1 = "アウト" Range("N4").Select ActiveCell.FormulaR1C1 = "合計" Range("O2").Select ActiveCell.FormulaR1C1 = "=COUNTIF(C[-5],""確定済(ヒット)"")" Range("O3").Select ActiveCell.FormulaR1C1 = "=COUNTIF(C[-5],""確定済(アウト)"")" Range("O4").Select ActiveCell.FormulaR1C1 = "=SUM(R[-2]C:R[-1]C)" Range("P2").Select ActiveCell.FormulaR1C1 = "=RC[-1]/R[2]C[-1]" Range("P3").Select ActiveCell.FormulaR1C1 = "=RC[-1]/R[1]C[-1]" Range("P4").Select ActiveCell.FormulaR1C1 = "=R[-2]C[-1]-R[-1]C[-1]" Range("Q2").Select ActiveCell.FormulaR1C1 = "利益合計" Range("Q3").Select ActiveCell.FormulaR1C1 = "損失合計" Range("Q4").Select ActiveCell.FormulaR1C1 = "損益合計" Range("R2").Select ActiveCell.FormulaR1C1 = "=IF(ISERROR(SUMIF(R[-1]C[-6]:INDEX(C[-6],COUNTA(C[-6])-1),"">0"")),""-"",(SUMIF(R[-1]C[-6]:INDEX(C[-6],COUNTA(C[-6])-1),"">0"")))" Range("R3").Select ActiveCell.FormulaR1C1 = "=IF(ISERROR(SUMIF(R[-2]C[-6]:INDEX(C[-6],COUNTA(C[-6])-1),""<0"")),""-"",(SUMIF(R[-2]C[-6]:INDEX(C[-6],COUNTA(C[-6])-1),""<0"")))" Range("R4").Select ActiveCell.FormulaR1C1 = "=R[-2]C+R[-1]C" Range("S2").Select ActiveCell.FormulaR1C1 = "利益平均" Range("S3").Select ActiveCell.FormulaR1C1 = "損失平均" Range("S4").Select ActiveCell.FormulaR1C1 = "損益平均" Range("T2").Select ActiveCell.FormulaR1C1 = "=RC[-2]/RC[-5]" Range("T3").Select ActiveCell.FormulaR1C1 = "=RC[-2]/RC[-5]" Range("T4").Select ActiveCell.FormulaR1C1 = "=RC[-2]/RC[-5]" Range("O2:O4").Select Selection.NumberFormatLocal = "0""回""" Range("P2:P3").Select Selection.NumberFormatLocal = "0.0%" Range("P4").Select Selection.NumberFormatLocal = "0""勝""" Range("R2:R4,T2:T4").Select Selection.NumberFormatLocal = "#,##0""円"";[赤]-#,##0""円""" Range("N2:T4").Select With Selection .HorizontalAlignment = xlCenter End With Range("N2:P2,N3:P3,N4:P4,Q2:R2,Q3:R3,Q4:R4,S2:T2,S3:T3,S4:T4").Select With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous End With Cells.Select Selection.Columns.AutoFit Range("A1").Select End Sub