ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   TRIM function (https://www.excelbanter.com/new-users-excel/146124-trim-function.html)

fitou_learn[_2_]

TRIM function
 
Is it possible to trim an entire worksheet?

Mike H

TRIM function
 
You could use a macro

Sub trimall()
Application.ScreenUpdating = False
Dim myRange As Range
Set myRange = Range("A1:D1000") '< Change to suit
For Each c In myRange
c.Select
c.Value = Trim(c.Value)
Next c
Application.ScreenUpdating = True
End Sub

Mike

"fitou_learn" wrote:

Is it possible to trim an entire worksheet?


fitou_learn[_2_]

TRIM function
 
Many thanks Mike. It worked a treat!

"Mike H" wrote:

You could use a macro

Sub trimall()
Application.ScreenUpdating = False
Dim myRange As Range
Set myRange = Range("A1:D1000") '< Change to suit
For Each c In myRange
c.Select
c.Value = Trim(c.Value)
Next c
Application.ScreenUpdating = True
End Sub

Mike

"fitou_learn" wrote:

Is it possible to trim an entire worksheet?



All times are GMT +1. The time now is 05:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com