Price-Earnings Ratio (P/E) Calculator for Excel
Calculate the P/E ratio instantly and learn how to implement it in Excel with our step-by-step guide. Perfect for investors, analysts, and finance professionals.
Complete Guide: How to Calculate Price-Earnings Ratio in Excel
The Price-Earnings (P/E) ratio is one of the most fundamental valuation metrics used by investors to determine whether a stock is overvalued, undervalued, or fairly valued. This comprehensive guide will walk you through:
- The exact formula for calculating P/E ratio
- Step-by-step instructions for Excel implementation
- Practical examples with real-world data
- How to interpret P/E ratio results
- Common mistakes to avoid
- Advanced applications for financial analysis
Understanding the P/E Ratio Formula
The P/E ratio is calculated using this simple formula:
P/E Ratio = Current Stock Price ÷ Earnings Per Share (EPS)
Where:
- Current Stock Price: The latest market price of one share of stock
- Earnings Per Share (EPS): The portion of a company’s profit allocated to each outstanding share of common stock, typically reported as:
- Trailing Twelve Months (TTM)
- Forward (estimated)
- Last Year (LY)
Step-by-Step Excel Calculation
- Set Up Your Data
Create a simple table in Excel with these columns:
Company Stock Price ($) EPS ($) P/E Ratio Example Corp 150.50 4.25 =B2/C2 - Enter the Formula
In the P/E Ratio column, enter the formula =Stock_Price_Cell/EPS_Cell. For our example, this would be =B2/C2.
- Format the Result
Right-click the P/E ratio cell → Format Cells → Number → Set decimal places to 2.
- Add Data Validation
To prevent errors:
- Select your stock price and EPS cells
- Go to Data → Data Validation
- Set “Allow” to “Decimal” and “Data” to “greater than” 0
- Create a Dynamic Dashboard
For advanced analysis:
- Create a line chart comparing P/E ratios over time
- Add conditional formatting to highlight high/low ratios
- Use data tables to show sensitivity analysis
Real-World Example with S&P 500 Data
Let’s calculate the P/E ratio for three major companies using their 2023 data:
| Company | Stock Price (May 2023) | TTM EPS | P/E Ratio | Industry Avg P/E | Comparison |
|---|---|---|---|---|---|
| Apple (AAPL) | $172.44 | $6.11 | 28.22 | 22.1 | Above average |
| Microsoft (MSFT) | $332.55 | $9.68 | 34.35 | 28.7 | Above average |
| Walmart (WMT) | $150.87 | $6.27 | 24.06 | 20.3 | Above average |
To implement this in Excel:
- Create a table with these columns
- Use the formula =B2/C2 for P/E Ratio
- Add a column with =IF(D2>E2, “Above average”, “Below average”) for comparison
- Apply conditional formatting to highlight above/below average values
Interpreting P/E Ratio Results
The P/E ratio tells you how much investors are willing to pay for $1 of earnings. Here’s how to interpret different ranges:
- Low P/E (0-15): Typically indicates:
- Potential undervaluation
- Mature companies with stable growth
- Possible financial distress (verify with other metrics)
- Average P/E (15-25): Suggests:
- Fair valuation for most industries
- Balanced growth expectations
- Market-neutral sentiment
- High P/E (25+): Often means:
- High growth expectations
- Potential overvaluation
- New industries or disruptive companies
- Market bubbles in extreme cases
Pro Tip:
Always compare a company’s P/E ratio to:
- Its own historical average
- Industry peers
- Market benchmarks (S&P 500 average P/E is ~20)
Common Mistakes to Avoid
- Using the Wrong EPS Figure
Always verify whether you’re using TTM, forward, or LY EPS. Mixing these can lead to incorrect valuations. The SEC’s EDGAR database is the most reliable source for official EPS figures.
- Ignoring Negative Earnings
Companies with negative earnings (losses) will show negative P/E ratios, which are meaningless for valuation. In these cases, use alternative metrics like Price-to-Sales or Price-to-Book.
- Comparing Across Industries
P/E ratios vary significantly by industry. Comparing a tech company (high P/E) to a utility (low P/E) is like comparing apples to oranges. Always use industry-specific benchmarks.
- Not Adjusting for One-Time Items
EPS can be distorted by non-recurring items. For accurate analysis, use “adjusted EPS” that excludes one-time gains/losses. This data is typically available in company filings or financial databases like Compustat.
Advanced Excel Techniques
For sophisticated financial analysis, implement these advanced Excel features:
- Data Tables for Sensitivity Analysis
Create a two-variable data table to see how P/E changes with different stock prices and EPS scenarios:
- Set up your base case with stock price in one cell and EPS in another
- Create a range of possible values for each variable
- Use Data → What-If Analysis → Data Table
- Select your P/E ratio formula as the column input cell
- Dynamic Charts with Scroll Bars
Add interactive controls to your P/E analysis:
- Go to Developer → Insert → Scroll Bar (Form Control)
- Link it to a cell that will adjust your stock price or EPS
- Create a line chart that updates as you scroll
- Automated Industry Comparisons
Use Excel’s Power Query to import industry average P/E data:
- Get data from financial APIs or websites
- Use Power Query to clean and transform the data
- Create a comparison table that automatically updates
- Monte Carlo Simulation
For probabilistic valuation:
- Set up distributions for stock price and EPS
- Use =NORM.INV(RAND(),mean,std_dev) for random values
- Run thousands of iterations to see P/E distribution
- Create a histogram of possible outcomes
Academic Research on P/E Ratios
Extensive academic research has been conducted on P/E ratios and their predictive power. Key findings include:
- Long-Term Performance: A 2000 study by Columbia Business School found that portfolios of low P/E stocks outperformed high P/E stocks by 4-6% annually over 20-year periods.
- Market Timing: Research from the National Bureau of Economic Research shows that when the S&P 500’s P/E ratio exceeds 25, forward 10-year returns average 4.2% annually, compared to 10.3% when P/E is below 15.
- Sector Variations: A 2018 paper in the Journal of Financial Economics documented that technology sector P/E ratios are structurally higher due to:
- Higher growth expectations
- Greater intangible assets
- Network effects in business models
| P/E Ratio Range | Frequency (1926-2022) | Avg. 10-Year Return | Standard Deviation |
|---|---|---|---|
| < 10 | 8% | 12.4% | 3.1% |
| 10-15 | 22% | 10.1% | 2.8% |
| 15-20 | 31% | 8.7% | 3.0% |
| 20-25 | 24% | 6.5% | 3.5% |
| > 25 | 15% | 4.2% | 4.2% |
Source: Yale School of Management (Robert Shiller’s dataset)
Excel Template for P/E Analysis
To create a professional P/E analysis template in Excel:
- Input Section
- Company name
- Current stock price (with data validation)
- EPS (TTM, Forward, LY in separate columns)
- Shares outstanding
- Industry average P/E
- Calculation Section
- P/E ratios for each EPS type
- Market capitalization (price × shares)
- P/E premium/discount to industry
- PEG ratio (P/E ÷ growth rate)
- Visualization Section
- Bar chart comparing company P/E to industry
- Line chart of historical P/E trends
- Gauge chart showing valuation status
- Analysis Section
- Automated interpretation based on P/E range
- Buy/hold/sell recommendation matrix
- Key risks and considerations
For a complete template, you can download our P/E Ratio Analysis Workbook which includes all these features plus macro-enabled automation.
Alternative Valuation Metrics
While P/E is valuable, professional analysts often use it in conjunction with other metrics:
| Metric | Formula | When to Use | Excel Implementation |
|---|---|---|---|
| Price-to-Book (P/B) | Market Cap ÷ Book Value | Asset-heavy companies (banks, industrials) | =Market_Cap/Book_Value |
| Price-to-Sales (P/S) | Market Cap ÷ Revenue | Early-stage companies with no earnings | =Market_Cap/Revenue |
| PEG Ratio | P/E ÷ Growth Rate | High-growth companies | =PE_Ratio/Growth_Rate |
| EV/EBITDA | Enterprise Value ÷ EBITDA | M&A transactions, capital-intensive businesses | =EV/EBITDA |
| Dividend Yield | Annual Dividend ÷ Stock Price | Income-focused investors | =Annual_Dividend/Stock_Price |
Automating P/E Calculations with Excel VBA
For power users, here’s a VBA macro to automate P/E calculations across multiple stocks:
Sub CalculatePERatios()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Stock Data")
' Find last row with data
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' Loop through each stock
For i = 2 To lastRow
If ws.Cells(i, 2).Value > 0 And ws.Cells(i, 3).Value <> 0 Then
' Calculate P/E ratio
ws.Cells(i, 4).Value = ws.Cells(i, 2).Value / ws.Cells(i, 3).Value
' Format as number with 2 decimal places
ws.Cells(i, 4).NumberFormat = "0.00"
' Add conditional formatting
If ws.Cells(i, 4).Value > 25 Then
ws.Cells(i, 4).Interior.Color = RGB(255, 200, 200) ' Light red
ElseIf ws.Cells(i, 4).Value < 15 Then
ws.Cells(i, 4).Interior.Color = RGB(200, 255, 200) ' Light green
Else
ws.Cells(i, 4).Interior.Color = xlNone
End If
Else
ws.Cells(i, 4).Value = "N/A"
End If
Next i
' Create chart
Dim chartObj As ChartObject
Set chartObj = ws.ChartObjects.Add(Left:=500, Width:=400, Top:=50, Height:=300)
chartObj.Chart.SetSourceData Source:=ws.Range("A1:D" & lastRow)
chartObj.Chart.ChartType = xlColumnClustered
chartObj.Chart.HasTitle = True
chartObj.Chart.ChartTitle.Text = "P/E Ratio Comparison"
MsgBox "P/E ratios calculated and chart created successfully!", vbInformation
End Sub
To implement this:
- Press Alt+F11 to open the VBA editor
- Insert a new module
- Paste the code above
- Create a button on your worksheet and assign this macro
- Ensure your data is in columns A (Company), B (Price), C (EPS)
Final Thoughts and Best Practices
Mastering P/E ratio analysis in Excel can significantly enhance your investment decision-making. Remember these best practices:
- Always use multiple periods: Compare TTM, forward, and LY P/E ratios for a complete picture
- Combine with other metrics: Never rely solely on P/E; use it with PEG, P/B, and others
- Understand the business: A high P/E might be justified for companies with strong competitive advantages
- Watch for accounting tricks: Some companies manipulate EPS through share buybacks or one-time items
- Update regularly: P/E ratios change daily with stock prices; set up automatic data refreshes
- Consider macroeconomic factors: Interest rates, inflation, and market sentiment all affect P/E ratios
For further study, we recommend these authoritative resources:
- SEC's Investor Bulletin on P/E Ratios
- CFI's Valuation Course (includes Excel templates)
- Khan Academy's Finance Section (free P/E ratio lessons)