Excel Formula to Calculate Rate of Return on Investment
Calculating the Rate of Return (ROI) is essential for investors to understand the profitability of an investment. While you can use our interactive calculator below to get instant results, understanding the underlying Excel formulas allows you to manage larger datasets and financial models effectively.
ROI & Excel Formula Generator
Total Gain/Loss:$0.00
Total ROI (%):0.00%
Annualized Return (CAGR):0.00%
= (B1 – A1) / A1
Assuming Initial Value in A1 and Final Value in B1.
= (B1 / A1) ^ (1 / C1) – 1
Assuming Years in C1.
function calculateROI() {
// Get input elements by ID strictly
var initialInput = document.getElementById("initialInvest");
var finalInput = document.getElementById("finalValue");
var timeInput = document.getElementById("timePeriod");
var resultBox = document.getElementById("results");
// Parse values
var initial = parseFloat(initialInput.value);
var final = parseFloat(finalInput.value);
var years = parseFloat(timeInput.value);
// Validation
if (isNaN(initial) || isNaN(final) || initial === 0) {
alert("Please enter valid investment amounts. The initial investment cannot be zero.");
return;
}
// 1. Calculate Profit
var profit = final – initial;
// 2. Calculate Simple ROI
var roi = (profit / initial) * 100;
// 3. Calculate CAGR (Compound Annual Growth Rate) if years provided
var cagr = 0;
var showAnnualized = false;
if (!isNaN(years) && years > 0) {
// Formula: ((Final / Initial) ^ (1 / Years)) – 1
// Handle negative bases if necessary (math limit), but for ROI usually strictly positive for CAGR logic usually
if (initial > 0 && final >= 0) {
cagr = (Math.pow((final / initial), (1 / years)) – 1) * 100;
showAnnualized = true;
}
}
// Display Numeric Results
document.getElementById("resProfit").innerHTML = "$" + profit.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2});
document.getElementById("resROI").innerHTML = roi.toFixed(2) + "%";
if (showAnnualized) {
document.getElementById("resCAGR").innerHTML = cagr.toFixed(2) + "%";
document.getElementById("annualizedRow").style.display = "flex";
document.getElementById("excelCagrContainer").style.display = "block";
} else {
document.getElementById("annualizedRow").style.display = "none";
document.getElementById("excelCagrContainer").style.display = "none";
}
// Generate Dynamic Excel Formula Strings
// We simulate that the user's input values are in cells
var roiFormulaStr = '= (' + final + ' – ' + initial + ') / ' + initial;
document.getElementById("excelRoiFormula").innerText = roiFormulaStr;
if (showAnnualized) {
var cagrFormulaStr = '= (' + final + ' / ' + initial + ')^(1/' + years + ') – 1';
document.getElementById("excelCagrFormula").innerText = cagrFormulaStr;
}
// Show results
resultBox.style.display = "block";
}
The Basic ROI Formula
The Return on Investment (ROI) is a performance measure used to evaluate the efficiency of an investment. The formula is conceptually simple: it calculates the benefit (return) of an investment relative to its cost.
ROI Formula:
ROI = (Current Value – Cost of Investment) / Cost of Investment
The result is usually expressed as a percentage or a ratio.
How to Calculate ROI in Excel
Excel does not have a dedicated "ROI" function because the math is straightforward arithmetic. However, you can easily build a formula to calculate it. Here is the step-by-step process:
Enter Data: Input your Initial Investment in cell A1 and your Final Value (or Ending Balance) in cell B1.
Input Formula: In cell C1, enter the following formula:
=(B1-A1)/A1
Format as Percentage: By default, Excel may show a decimal (e.g., 0.15). To see it as a percentage (15%), select cell C1 and press Ctrl + Shift + % or click the "%" button in the Home ribbon.
Calculating Annualized Rate of Return (CAGR) in Excel
If your investment spans multiple years, a simple ROI calculation can be misleading because it doesn't account for the time period. For this, you need the Compound Annual Growth Rate (CAGR).
For example, if you invested $10,000 (A1) and it grew to $15,000 (B1) over 5 years (C1), the formula would be:
=(B1/A1)^(1/C1)-1
Using the XIRR Function for Complex Cash Flows
The formulas above assume a single initial investment and a single final value. If you have multiple deposits and withdrawals at different dates, the basic formulas will not be accurate. For these scenarios, you should use the XIRR function in Excel.
Syntax: =XIRR(values, dates)
Values: A range of cells containing the cash flows (investments are negative numbers, returns are positive).
Dates: A range of cells corresponding to the dates of those payments.
Frequently Asked Questions
Why is my Excel ROI result a decimal like 0.25?
Excel calculates math strictly. 0.25 is mathematically equivalent to 25%. To fix this visually, you need to change the cell formatting to "Percentage" using the formatting toolbar.
Can I use the RRI function in Excel?
Yes, newer versions of Excel include the RRI function, which returns an equivalent interest rate for the growth of an investment. The syntax is =RRI(number_of_periods, present_value, future_value).
How do I handle dividends in the ROI Excel formula?
If you received dividends, you must add them to your "Current Value" or "Net Profit" numerator. The formula becomes: =((Current Value + Total Dividends) - Initial Cost) / Initial Cost.