how can i trim entire sheet?
vb macro needed
how can i trim entire sheet?
vb macro needed
Hi anilg0001 ,i found this after google![]()
Sub CleanSelection() Dim c As Range, rng As Range Set rng = Intersect(Selection, Selection.Parent.UsedRange) If rng Is Nothing Then MsgBox "No cells with values!" Exit Sub End If For Each c In rng If Not IsError(c) Then c.Value = MEGACLEAN(c) End If Next c End Sub Function MEGACLEAN(varVal As Variant) Dim NewVal As Variant If IsMissing(varVal) Then Exit Function NewVal = Trim(varVal) 'remove spaces NewVal = Application.WorksheetFunction.Clean(NewVal) 'remove most unwanted characters NewVal = Application.WorksheetFunction.Substitute(NewVal, Chr(127), "") 'remove ASCII#127 NewVal = Application.WorksheetFunction.Substitute(NewVal, Chr(160), "") 'remove ASCII#160 MEGACLEAN = NewVal End Function
![]()
-If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".
-Always upload a workbook before start your question
To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.
+++ If my answer(s) helped you, please add me reputation by click on * +++
its is not working sir
means nothing happen
last blank space in some cell still haveing
Can you upload the sample that can't trim. May need see the actual problem. Thanks
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks