Loading...
「ツール」は右上に移動しました。
利用したサーバー: natural-voltaic-titanium
7いいね 380回再生

How to Keep Full Sentences Within Character Limits In Excel

How to Keep Full Sentences Within Character Limits in Excel

When I started my website msexceltutorial.com I came across some difficulties regarding SERP (Search Engine Result Page). When we search on any search engine, we get results. If you observe there are snippets of the content on the SERP also. And those snippets have character limits. Now the problem is that when I prepare those snippets sometimes the character limit prevents me writing full sentences and even words. Now I need a way to keep full sentences with character limits in excel. I can do it with VBA but I need a neat solution without the complexity of writing VBA code. I want to limit characters in Excel cell and keep only full sentences using formula.
Smart approach would be to trim the text while preserving the sentence structure. In Excel, this can be achieved by leveraging functions like LEFT(), FIND(), and SUBSTITUTE().
Before going forward lets deep dive into these functions:
LEFT Function:    • How to use LEFT Function In Excel  
Find Function:    • How to Use FIND Function in Excel  
Substitute Function:    • How to Use SUBSTITUTE Function in Excel  

Now let’s walk through a formula that will help you limit text to a specific number of characters (in this case, 400 characters), while ensuring that the text does not break in the middle of a sentence.

=LEFT(A2,FIND("/",SUBSTITUTE(A2, ".","/",400-LEN(SUBSTITUTE(LEFT(A2,400), ".","")))))

Formula Breakdown:

1. LEFT(A2, 400):
This part of the formula extracts the first 400 characters from cell A2. It is the base for limiting the text to 400 characters.
If this function was used alone, it would cut the text at exactly the 400th character, which might result in an incomplete sentence.

2. SUBSTITUTE(A2, ".", "/"):
This section of the formula replaces all periods (".") in the string with forward slashes ("/"). The reason for this is to help us locate the last full stop within the 400-character limit.
Replacing periods with a slash is a temporary step that makes it easier to identify where sentences naturally end.

3. 400 - LEN(SUBSTITUTE(LEFT(A2,400), ".", "")):
This part calculates how many periods (i.e., sentence endings) are present within the first 400 characters.
By substituting all periods with an empty string, the LEN() function counts the length of the string without periods, which allows you to determine how many periods were present originally. Subtracting this length from 400 gives the number of periods within the 400-character limit.

4. FIND("/", SUBSTITUTE(A2, ".", "/", ...)):
After temporarily replacing the periods with slashes, FIND() locates the position of the last slash (which was originally a period) before the 400-character limit.
This ensures that we capture complete sentences within the limit, stopping at the last full stop.

5. LEFT(A2, FIND(...)):
Finally, the LEFT() function is used again to return the portion of the text from cell A2, but now it stops at the position where the last period (now a slash) was found, ensuring that the text ends with a complete sentence.

In plain sentences here’s how the formula works:

Excel will extract the first 400 characters.
It will count how many sentences (marked by periods) are within those 400 characters.
The formula then locates the last period within this limit, ensuring that the extracted text does not break in the middle of a sentence.
Now if you have different character limit you can change the 400 limit to that limit inside the formula. The formula will not break. It will work just fine.


Thanks for watching.
----------------------------------------------------------------------------------------
Support the channel with as low as $5
www.patreon.com/excel10tutorial
----------------------------------------------------------------------------------------
Please subscribe to #excel10tutorial
goo.gl/uL8fqQ

Here goes the most recent video of the channel:
bit.ly/2UngIwS

Playlists:

Excel Tutorial for Beginners: goo.gl/UDrDcA
Intermediate Excel Tutorial: tinyurl.com/59a837py
Advance Excel Tutorial: goo.gl/ExYy7v
Excel Text Case Conversion Techniques: goo.gl/xiP3tv
Combine Workbook & Worksheets: bit.ly/2Tpf7DB
All About Comments in Excel: bit.ly/excelcomments
Excel VBA Programming Course: bit.ly/excelvbacourse
ChatGPT Excel Mastermind: tinyurl.com/46kn7tmd

Social media:
Facebook: facebook.com/excel10tutorial
Twitter: twitter.com/excel10tutorial
Blogger: excel10tutorial.blogspot.com/
Tumblr: excel10tutorial.tumblr.com/
Instagram: www.instagram.com/excel_10_tutorial
Hubpages: hubpages.com/@excel10tutorial
Quora: bit.ly/3bxB8JG
Website: msexceltutorial.com/

Become a member and enjoy exclusive perks while supporting the channel you love!
youtube.com/channel/UCvYWtCPVbIDYLyNqB4lRIaw/join

コメント