How to Extract Emails from Excel & CSV Files

Four practical methods to pull email addresses out of spreadsheets

← Back to Email Extractor

Why Extract Emails from Spreadsheets?

Excel files and CSVs are among the most common places where email addresses end up scattered across your data. Whether you are dealing with a CRM export, a contact list from a conference, survey responses, or a database dump with mixed columns, you often need to pull out just the email addresses for a mailing list, a migration, or a cleanup task.

The challenge is that emails are not always neatly stored in a dedicated column. They can be buried inside cells that also contain names, phone numbers, or free-text notes. Sometimes a single cell holds multiple email addresses separated by commas or semicolons. The methods below cover every scenario – from the quickest drag-and-drop approach to fully automated scripts.

Method 1: Using Our Free Online Tool

The fastest way to extract emails from an Excel or CSV file is to use our free online email extractor. No installation, no sign-up, and your data never leaves your browser.

  1. Open extract-emails.com in any modern browser.
  2. Drag and drop your .xlsx, .xls, or .csv file onto the upload area – or click to browse your file system.
  3. The tool scans every cell in every sheet and extracts all email addresses automatically.
  4. Review the results, remove duplicates with one click, and copy or download the list.

Because the extraction runs entirely in your browser using JavaScript, your spreadsheet data is never uploaded to a server. This makes the tool safe for confidential or sensitive files such as HR records or customer databases.

The tool handles multi-sheet workbooks, cells with mixed content, and files with thousands of rows without any issues. For most users, this is the recommended approach.

Email Marketing Tool

Method 2: Excel Formulas

If you prefer to stay inside Excel, you can use a combination of built-in functions to extract an email address from a cell that contains mixed text. This approach works well when each cell contains at most one email address.

The Formula

Assuming your text is in cell A1, the following array formula extracts the email address:

=IFERROR(MID(A1,FIND("@",A1)-FIND(" ",
  SUBSTITUTE(LEFT(A1,FIND("@",A1)-1)," ","",-1)&" ",
  LEN(LEFT(A1,FIND("@",A1)-1))-LEN(SUBSTITUTE(
  LEFT(A1,FIND("@",A1)-1)," ",""))),
  FIND(" ",MID(A1,FIND("@",A1),255)&" ")+
  FIND("@",A1)-FIND(" ",SUBSTITUTE(LEFT(A1,
  FIND("@",A1)-1)," ","",-1)&" ",LEN(LEFT(A1,
  FIND("@",A1)-1))-LEN(SUBSTITUTE(LEFT(A1,
  FIND("@",A1)-1)," ","")))-1),"")

This formula works by locating the @ symbol, then scanning left and right for the nearest space to isolate the full email address. If no @ is found, it returns an empty string thanks to IFERROR.

A Simpler Alternative with TEXTJOIN (Microsoft 365)

If you use Microsoft 365 or Excel 2021+, you can combine TEXTJOIN with FILTERXML or leverage dynamic arrays. However, for reliable email extraction from truly messy data, formula-based approaches quickly become unwieldy. Consider using VBA or our online tool instead.

Email Marketing Tool

Method 3: VBA Macro for Excel

A VBA macro gives you full regex support inside Excel. This approach can scan an entire worksheet and collect every email address into a new sheet or column.

Step-by-Step Setup

  1. Open your workbook and press Alt + F11 to open the VBA editor.
  2. Go to Tools → References and check Microsoft VBScript Regular Expressions 5.5.
  3. Insert a new module (Insert → Module) and paste the code below.
  4. Close the editor and run the macro from Developer → Macros.
VBA macro – extract all emails from the active sheet
Sub ExtractEmails()
    Dim reg As New RegExp
    Dim cell As Range
    Dim matches As MatchCollection
    Dim m As Match
    Dim ws As Worksheet
    Dim outRow As Long

    ' Set up the regex pattern
    reg.Pattern = "[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}"
    reg.Global = True
    reg.IgnoreCase = True

    ' Create an output sheet
    Set ws = Worksheets.Add
    ws.Name = "Extracted Emails"
    ws.Range("A1").Value = "Email"
    outRow = 2

    ' Loop through every used cell on the source sheet
    Dim src As Worksheet
    Set src = Worksheets(1)
    For Each cell In src.UsedRange
        If Not IsEmpty(cell.Value) Then
            If reg.Test(CStr(cell.Value)) Then
                Set matches = reg.Execute(CStr(cell.Value))
                For Each m In matches
                    ws.Cells(outRow, 1).Value = m.Value
                    outRow = outRow + 1
                Next m
            End If
        End If
    Next cell

    ' Remove duplicates
    If outRow > 2 Then
        ws.Range("A1:A" & outRow - 1).RemoveDuplicates Columns:=1, Header:=xlYes
    End If

    MsgBox "Done! Found " & (outRow - 2) & " emails (before dedup).", vbInformation
End Sub

This macro creates a new sheet called "Extracted Emails" and populates it with every email address found across all cells on the first worksheet. Duplicates are removed automatically at the end.

Email Marketing Tool

Method 4: Python with openpyxl and pandas

For large files, recurring tasks, or integration into a data pipeline, Python is the most flexible option. The openpyxl library reads .xlsx files, and pandas handles both Excel and CSV with ease.

Using openpyxl

Extract emails from every cell in an Excel workbook
import re
from openpyxl import load_workbook

def extract_emails_from_excel(filepath):
    pattern = re.compile(r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}')
    emails = set()
    wb = load_workbook(filepath, read_only=True, data_only=True)

    for sheet in wb.sheetnames:
        ws = wb[sheet]
        for row in ws.iter_rows(values_only=True):
            for cell in row:
                if cell and isinstance(cell, str):
                    emails.update(pattern.findall(cell))

    wb.close()
    return sorted(emails)

# Usage
results = extract_emails_from_excel("contacts.xlsx")
for email in results:
    print(email)

Using pandas

Extract emails from a CSV or Excel file with pandas
import re
import pandas as pd

def extract_emails_from_dataframe(filepath):
    pattern = re.compile(r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}')

    # Read CSV or Excel depending on extension
    if filepath.endswith('.csv'):
        df = pd.read_csv(filepath, dtype=str)
    else:
        df = pd.read_excel(filepath, dtype=str, sheet_name=None)
        # Concatenate all sheets into one DataFrame
        df = pd.concat(df.values(), ignore_index=True)

    emails = set()
    for col in df.columns:
        for value in df[col].dropna():
            emails.update(pattern.findall(str(value)))

    return sorted(emails)

# Usage
emails = extract_emails_from_dataframe("data.csv")
print(f"Found {len(emails)} unique emails")
for e in emails:
    print(e)

Both scripts automatically deduplicate results using a Python set. The pandas approach is particularly convenient because it handles CSV and multi-sheet Excel files with the same function.

Email Marketing Tool

Working with CSV Files

CSV (Comma-Separated Values) files are simpler than Excel workbooks – they are plain text files with no formatting, formulas, or multiple sheets. This makes them especially easy to work with.

  • Paste directly: Open the CSV in a text editor, select all the text, and paste it into our online email extractor. The tool will find every email address in the raw text.
  • Upload the file: You can also drag and drop the .csv file directly into the tool, just like an Excel file.
  • Command line: On Linux or macOS, a simple one-liner does the job:
Bash – extract emails from a CSV file
grep -oE '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' data.csv | sort -u

This pipes the file through grep with the standard email regex, then sorts and deduplicates the output. It works on files of any size and finishes in seconds even for multi-gigabyte CSVs.

Tips for Handling Large Files and Cleaning Data

When working with large spreadsheets or messy data exports, keep these practical tips in mind:

  • Handle large files in chunks: If your Excel file has hundreds of thousands of rows, use openpyxl in read-only mode (as shown above) or process the CSV in chunks with pandas.read_csv(filepath, chunksize=10000). This keeps memory usage low.
  • Deduplicate early: Use a set in Python, RemoveDuplicates in Excel, or the built-in deduplication in our online tool. Removing duplicates before further processing saves time and avoids sending repeated emails.
  • Normalize before comparing: Convert all extracted emails to lowercase before deduplication. John@Example.com and john@example.com are the same mailbox but will be treated as different strings unless you normalize case.
  • Watch for encoding issues: CSV files can use different character encodings (UTF-8, Latin-1, Windows-1252). If you see garbled characters, specify the encoding explicitly: pd.read_csv("file.csv", encoding="latin-1").
  • Validate after extraction: Not every string that looks like an email is deliverable. Consider running extracted addresses through a basic syntax check and optionally an MX-record lookup to verify the domain exists.
  • Strip whitespace: Cells in spreadsheets often contain leading or trailing spaces. Always .strip() your extracted emails to avoid issues with downstream systems.

Extract Emails from Your Spreadsheet Now

Upload your Excel or CSV file and get a clean list of email addresses – free, instant, and private.

Open Email Extractor
DD
About the Author

Daniel Dorfer worked for nearly four years in technical support at GMX, one of Germany’s largest email providers, and for almost two years at united domains, a leading domain hoster and registrar. He is a founding member of the KIBC (KI Business Club). This website was built entirely with the help of Claude Code (Opus 4.6) by Anthropic.

Email Marketing Tool