Support Request: Trim Cell Function for more than 255 Characters

DrHacker

New Member
Joined
Jun 4, 2018
Messages
33
Experts, i have this Macro code used for Clean / Trim selected cells, but it shows me an error if the length its more than 255 Characters. There is a way to adjust the code do paste the full Clean Trim string if its more than that quantity (255+)?

VBA Code:
Sub CleanTrimCells_Evaluate()

    Dim Area As Range

If Selection.Cells.Count = 1 Then

Set rng = Selection

Else

Set rng = Selection.SpecialCells(xlCellTypeConstants)

End If

For Each Area In rng.Areas
Area.Value = Evaluate("IF(ROW(" & Area.Address & "),CLEAN(TRIM(" & Area.Address & ")))")
Next Area

End Sub

Thanks in advance
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
How about
VBA Code:
Sub DrHacker()
   Dim Cl As Range, Rng As Range
   
   Set Rng = Selection.SpecialCells(xlConstants)
   With Application
      For Each Cl In Rng
         Cl.Value = .Clean(.Trim(Cl.Value))
      Next Cl
   End With
End Sub
 
Upvote 0
Nice , Works flawless :)

How about
VBA Code:
Sub DrHacker()
   Dim Cl As Range, Rng As Range
  
   Set Rng = Selection.SpecialCells(xlConstants)
   With Application
      For Each Cl In Rng
         Cl.Value = .Clean(.Trim(Cl.Value))
      Next Cl
   End With
End Sub
ce,
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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
Back
Top