How to Split Cells to Get Last Value in Google Sheets (4 Methods)

Getting the last element of cells is often necessary. For instance, we may need to separate different portions of a person’s name from a single string separated by a comma or space. We have multiple different ways in Google Sheets for performing such tasks. This article serves you a comprehensive guide to split and get last element of cells in Google Sheets with 4 suitable methods.

google sheets split get last


A Sample of Practice Spreadsheet

You can download the spreadsheets from the link below. The spreadsheets contain a dataset we use here. After downloading you can practice on your own as we demonstrate here.


4 Suitable Methods to Split Cells and Get Last Value in Google Sheets

The following dataset contains ID, First Name and Last Name of persons in a single cell separated by a comma. Using this dataset we are going to demonstrate three methods of splitting a cell and extracting the Last Name only.

Dataset of splitting and get last element in Google Sheets


1. Using SPLIT Function

The SPLIT function splits cells into columns based on a given delimiter. However, we can get the last column only by employing INDEX and COUNTA functions with it.

πŸ“Œ Steps:

  • First of all, we select cell C5.
  • Then we write down the formula below in the formula bar of cell C5.
=INDEX(SPLIT(B5,","),0,COUNTA(SPLIT(B5,",")))

Use of SPLIT function to split and get last element in Google Sheets

Formula Breakdown

  • SPLIT(B5,”,”)

The SPLIT function splits the text of the cell B5 into columns by using comma as delimiters.

  • COUNTA(SPLIT(B5,”,”)

The COUNTA function returns the number of columns of the splitting text and the return value is used as an argument of the COUNTA function.

  • INDEX(SPLIT(B5,”,”),0,COUNTA(SPLIT(B5,”,”)))

Finally, the INDEX function returns the last column of the splitting text.

  • As a result, we get the Last Name of the first person in the selected cell as follows.
  • Afterward, we use the fill handle tool to get the Last Name of subsequent rows.

Fill handle operation to get the last element using SPLIT function

  • Finally, we get the following result where only the Last Name is extracted by splitting the corresponding cell.

Final result of the SPLIT function to split and get last element

Read More: How to Split Text to Columns Using Formula in Google Sheets


2. Applying the REGEXEXTRACT Function

We can also split and get last element of a cell by applying the REGEXEXTRACT function. We have to write a regular expression based on text when using this function.

πŸ“Œ Steps:

  • Initially, we select cell C5 as earlier.
  • Then we write down the formula below in the formula bar of cell C5.
=REGEXEXTRACT(B5,"[^,]+$")

Application of REGEXEXTRACT function to split and get last element in Google Sheets

  • Consequently, we get the Last Name of the first person in the selected cell as indicated.
  • Next, we use the fill handle tool to get the Last Name for other rows.

Fill handle operation to get the last element using the REGEXEXTRACT function

  • Once we complete the fill handle operation we got the following result.

Final result of REGEXEXTRACT function

Read More: [Solved!] Split Text to Columns Is Not Working in Google Sheets


Similar Readings


3. Combining TRIM and LEN Functions

There are a lot of functions in Google Sheets. We can use a few of them combinedly to get the desired result. In this method, we demonstrate how to use a combination of various functions to split and get the last element of cells.

πŸ“Œ Steps:

  • At the very beginning, we select cell C5.
  • Next, we insert the formula below in the formula bar.
=TRIM(RIGHT(SUBSTITUTE(B5," ",REPT(" ",LEN(B5))),LEN(B5)))

Combination of various functions to split and get last element in Google Sheets

Formula Breakdown

  • LEN(B5)

The LEN function finds the length of given cell B5.

  • REPT(” “,LEN(B5))

This returns the repetition of blank string for the given number of times with the help of the REPT function.

  • SUBSTITUTE(B5,”,”,REPT(” “,LEN(B5))

The SUBSTITUTE function searches for comma in the given text and then replace them with repetitive blank spaces.

  • RIGHT(SUBSTITUTE(B5,” “,REPT(” “,LEN(B5)))

The RIGHT function returns a string that results from the SUBSTITUTE function from the right side.

  • TRIM(RIGHT(SUBSTITUTE(B5,” “,REPT(” “,LEN(B5))),LEN(B5)))

Finally, the TRIM function returns the targeted Last Name only from the given text by removing whitespaces.

  • As a result, we get the Last Name as expected in the selected cell.
  • After that, we use the fill handle tool to get the Last Name in other rows.

Fill handle operation to get the last element using a combination of various functions

  • Completing the fill handle operation gives us the following result.

Result of combination of functions for splitting cells and get last element

Read More: How to Split Cell by Comma in Google Sheets (2 Easy Methods)


4. Merging RIGHT and FIND Functions

We can perform the task of splitting and getting the last element on some occasions by merging the RIGHT and FIND functions.

πŸ“Œ Steps:

  • Firstly, we select cell C5 as earlier.
  • Then we insert the formula below in the formula bar.
=RIGHT(B5,LEN(B5)-FIND(",",B5))

Merging RIGHT and FIND function to get the last value of cells in Google Sheets

Formula Breakdown

  • FIND(“,”,B5)

The FIND function finds the position of the first comma within the text of given cell B5.

  • LEN(B5)-FIND(“,”,B5)

This returns the number of characters we want to get from the right side of the text of the given cell.

  • RIGHT(B5,LEN(B5)-FIND(“,”,B5))

The RIGHT function returns the substring of the text of cell B5 based on the given condition.

  • Here, we get both First Name and Last Name instead of getting the Last Name.

Merging RIGHT and FIND returns First Name and Last Name instead of Last Name only

  • However, we can still split cells and get the Last Name only using the same formula if the cells don’t contain person’s ID like below which means if there were only two data separated by one comma we could get perfect result.
  • Finally, we drag down the fill handle tool to get the Last Name for all the rows.

Fill handle operation to get the last element by merging RIGHT and FIND functions

  • As a result, we get the Last Name in all the rows like the methods we have already discussed.

Result of merging RIGHT and FIND functions for splitting cells and get last element

Note:

This method is not convenient for strings that contain more than one comma. If there is more than one comma, it would return the whole string part after the first comma which might not be our desired result.

Read More: How to Split String Using Apps Script in Google Sheets


Things to Remember

  • Be careful about the use of delimiters.
  • Try to use the REGEXEXTRACT function whenever possible because you can customize it to your needs.

Conclusion

In conclusion, splitting cells and getting the last element may be useful in some cases. I believe from now on you can easily split and get last element of cells in Google Sheets. Furthermore, If you have any questions regarding this article feel free to comment below and I will try to reach out to you soon. Visit our website OfficeWheel for the most useful articles.


Related Articles

Laku

Laku

Hey, I'm Zahidul Islam Laku. I completed my graduation from Bangladesh University of Science and Technology (BUET). I write articles about a variety of tech topics. I enjoy using my abilities as a creative thinker and problem-solver to develop original solutions to issues.

We will be happy to hear your thoughts

Leave a reply

OfficeWheel
Logo