Macro For Excel Text Limit & Conditional Formatting Formula

xstream

New Member
Joined
Dec 31, 2016
Messages
1
As excel has a 32,767 characters limit for per cell when applying wrap text. I am facing issue identifying the ones (out of tons of data) of which has exceeded the character limit.

Is there a Marco script that will allow the following to be done?
1) When cell text exceeded 32,767 characters, create new row below and merge the cells together. If still unable to display all characters in merge cell, then create a new row and merge them again until all characters (text) is displayed in that cell.


As for conditional formatting, what is the formula to highlight cells that is more than 32,767 characters.

Thank you :)
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Logit

Well-known Member
Joined
Aug 31, 2016
Messages
3,998
.
.
Code:
=LEN(E3)>6
...Change Cell reference and characters number as needed.
.

.
.
Untested :vba - Remove / overcome / exceed / overtake maximum characters limit of Excel cell - Stack Overflow
.

Thanks to Darren (see comments above) the best and safest solution is to split the string into different cells.
The following code splits the string into parts with lenght < 32,000 characters. It add the parts to an array and then it writes the parts to the needed number of adjacent cells:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; white-space: inherit;">iRow = ws.Cells(Rows.Count,1).End(xlUp).Offset(1,0).Row
col
=1

' Get string from txtEncodedImage text input
sArray
= SplitStr(txtEncodedImage.Value,32000)

For i = LBound(sArray)To UBound(sArray)
ws
.Cells(iRow, col + i).Value = sArray(i)
Next i


PublicFunction SplitStr(ByVal str AsString,ByVal numOfCharacters AsLong)AsString()
Dim sArray()AsString
Dim nCount AsLong
Dim c AsLong
c
= Len(str)\ numOfCharacters
If c * numOfCharacters = Len(str)Then
ReDim sArray(1To c)
Else
ReDim sArray(1To c +1)
EndIf
For c =1To Len(str)Step numOfCharacters
nCount
= nCount +1
sArray
(nCount)= Mid(str, c, numOfCharacters)
Next
SplitStr
= sArray
EndFunction</code>

<tbody>
</tbody>
 

Watch MrExcel Video

Forum statistics

Threads
1,129,377
Messages
5,635,900
Members
416,887
Latest member
SheriE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top