How to use MID Function in Google Sheets
Last Updated :
02 Jan, 2025
Handling textual data in spreadsheets often involves tasks like splitting information, extracting specific elements, or organizing text for analysis. The MID function in Google Sheets simplifies these processes by allowing users to extract specific parts of a text string. Whether you’re working with email addresses, product IDs, or file names, the MID function offers a versatile solution for precise text manipulation and data organization. This guide provides practical examples and step-by-step instructions for using the MID function, along with advanced combinations for more complex scenarios.
Google Sheets MID Function
The MID function in Google Sheets helps you extract a specific section of text from a string based on the starting position and the number of characters you want. It’s ideal for splitting structured text, such as product codes, serial numbers, or names.
How It Works
The MID function extracts characters from a text string starting at a specified position and for a defined length.
- Input the text: Provide the cell reference or text string to work with.
- Specify the start position: Determine where to begin extracting characters.
- Define the length: Indicate how many characters to extract from the start position.
MID Function Syntax in Google Sheets
=MID(text, start_num, num_chars)
Parameters:
- text: (Required) The text string or cell reference containing the text to extract from.
- start_num: (Required) The position (number) of the first character to extract.
- num_chars: (Required) The number of characters to extract from the starting position.
How to use the MID Function in Google Sheets
The MID function in Google Sheets allows you to extract a specific portion of text from a string by defining the starting point and the number of characters you want to extract.
Step 1: Set Up the Data and Select a Cell
Create a table with text data. For example, let’s say you have product codes and you want to extract specific parts of them. Select a Cell for the result of formula.
Set Up the Data >> Select a CellIn a new column (e.g., Column C), use the MID function to extract part of the Product Code. Suppose you want to extract 3 characters starting from position 4 in the Product Code. Enter the formula in cell C2:
=MID(B2, 4, 3)
Explanation:
- B2: The cell reference that contains the text (Product Code).
- 4: The starting position in the text (starting from the 4th character).
- 3: The number of characters to extract.
Enter the MID FormulaClick the small square in the bottom-right corner of the cell (C2) and drag it down to fill the formula for the remaining rows.
Result Appeared >> Drag the Formula Step 4: View the Results
The MID function will extract the specified characters from each Product Code. After applying the formula, your results will look like this:
View the ResultThe MID function in Google Sheets is versatile for handling text. Here are some practical examples for MID function to extract and manage data efficiently using Google Sheets functions for text:
Example 1: Extracting Email Domains
Extract the domain (e.g., "gmail.com") from email addresses in cell A1
.
Formula:
=MID(A1, FIND("@", A1) + 1, LEN(A1) - FIND("@", A1))
- Use Case: Organize email data for marketing or analysis.
- Example: From "[email protected]," it extracts "gmail.com."
Example 2: Splitting Product IDs
Split a product ID like "SKU-1234-AB" to isolate the numeric portion "1234".
Formula:
=MID(A1, 5, 4)
- Use Case: Extract meaningful components from structured product IDs.
- Example: From "SKU-1234-AB," it returns "1234."
Extract file extensions such as ".png" from filenames in cell A1
.
Formula:
=MID(A1, FIND(".", A1) + 1, LEN(A1) - FIND(".", A1))
- Use Case: Classify files based on type for better organization.
- Example: From "image.png," it extracts "png."
These practical examples show how to efficiently use MID and FIND functions for text extraction and data processing in Google Sheets.
Combining MID with Other Functions
The MID function becomes even more powerful when combined with other functions for advanced text manipulation. Here are some practical combinations:
1. MID + FIND
Extract dynamic substrings based on specific characters or patterns.
Formula:
=MID(A1, FIND("-", A1) + 1, FIND("-", A1, FIND("-", A1) + 1) - FIND("-", A1) - 1)
- Use Case: Extract text between two dashes in a string like "SKU-1234-AB".
- Example: From "SKU-1234-AB," it extracts "1234."
2. MID + CONCATENATE
Combine extracted substrings with additional text or characters.
Formula:
=CONCATENATE(MID(A1, 1, 3), "-", MID(A1, 4, 4))
- Use Case: Reformat IDs or add separators for better readability.
- Example: From "SKU1234," it creates "SKU-1234."
3. MID + LEN
Handle variable-length strings by adjusting the number of characters dynamically.
Formula:
=MID(A1, 3, LEN(A1)-2)
- Use Case: Remove the first two characters while keeping the rest of the text.
- Example: From "ABC12345," it returns "C12345."
These combinations allow the MID function to handle dynamic scenarios like text extraction, formatting, and data manipulation efficiently in Google Sheets.
Also Read:
Conclusion
The MID function in Google Sheets is a powerful tool for tackling a wide range of text-related challenges, from extracting email domains to segmenting product IDs. By leveraging its flexibility and combining it with other functions like FIND, CONCATENATE, and LEN, users can handle complex tasks with greater efficiency. Experimenting with these techniques will not only enhance your data manipulation skills but also streamline your workflow in Google Sheets.
Similar Reads
How to Use RIGHT function in Google Sheets
Text manipulation can often feel tedious, especially when working with extensive datasets, but functions like the RIGHT function in Google Sheets offer a simple way to extract specific characters from the end of text strings. Whether you're cleaning up information, preparing reports, or extracting e
7 min read
How to use LOWER Function in Google Sheets
The LOWER function in Google Sheets is a simple yet highly effective tool to convert all text in a cell to lowercase. Itâs especially useful when you're dealing with inconsistent capitalization in your data or when you want to standardize text entries across your spreadsheet. Whether you're working
8 min read
How to use the YEAR Function in Google Sheets
The YEAR function in Google Sheets is a straightforward yet essential tool for working with date-related data. It allows users to quickly extract the year from a date, making it invaluable for tasks like organizing data by year, tracking trends over time, or generating time-based reports. Whether yo
4 min read
How to Use the UPPER Function in Google Sheets
Want to capitalize text in Google Sheets without manual editing? The UPPER function in Google Sheets is a simple yet powerful tool that transforms any text string into uppercase letters instantly. Whether you're managing mailing lists, form responses, or standardizing data formats, this formula simp
5 min read
How to Use Add-Ons in Google Sheets
Google Sheets add-ons offer an incredible way to expand the functionality of your spreadsheets, making them more efficient and versatile for various tasks. Whether youâre looking to automate repetitive workflows, perform advanced data analysis, or customize your sheets for specific needs, add-ons fr
3 min read
How to Use INDEX MATCH in Google Sheets
Sorting through large datasets can be challenging, but combining the Google Sheets INDEX function with the Google Sheets MATCH function provides an efficient way to retrieve and locate specific data points. These two powerful tools help you create flexible formulas that dynamically reference rows an
8 min read
MONTH Function in Google Sheets
The MONTH function in Google Sheets is a simple yet essential tool for extracting the month from a given date. Whether youâre handling financial data, managing project timelines, or tracking time-specific trends, this function helps you analyze and organize information based on months. Learning how
5 min read
How to Use Data Bars in Google Sheets
Data bars in Google Sheets visually represent your data, making it easier to compare values within a range. By applying data bars through Conditional Formatting, you can instantly see trends, differences, and patterns in your dataset. This feature is especially useful for highlighting high or low va
5 min read
How to Use the IFS Function in Google Sheets: A Complete Guide
Google Sheets offers a variety of powerful functions to handle data, and one of the most useful is the IFS function. The IFS function allows you to evaluate multiple conditions and return a value that corresponds to the first true condition, making it an efficient tool for handling complex logical t
7 min read
How to Create and Use Pivot Tables in Google Sheets
Pivot tables in Google Sheets are indispensable for turning raw data into meaningful insights. Whether youâre tracking sales, analyzing marketing metrics, or managing financial data, pivot tables allow users to create dynamic data summaries with ease. This tutorial covers how to use pivot tables in
6 min read