ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting blanks from the end of values in cells (https://www.excelbanter.com/excel-programming/293703-re-deleting-blanks-end-values-cells.html)

Gord Dibben

Deleting blanks from the end of values in cells
 
Todd

Sub TRIM_EXTRA_SPACES()
Dim cell As Range
For Each cell In Selection
If (Not IsEmpty(cell)) And _
Not IsNumeric(cell.Value) And _
InStr(cell.Formula, "=") = 0 _
Then cell.Value = Application.Trim(cell.Value)
Next
End Sub

Gord Dibben Excel MVP

On Wed, 31 Mar 2004 06:50:42 -0800, "Todd Huttenstine"
wrote:

I have a very big range of data on a worksheet. The range
is located on worksheet Renewals A:F. Another worksheet
Wkly Renewals has a pivot table referencing that range.
Some values in the range may have a space (" ") at the end
of the value and needs to be removed.

For example cell D205 should be "Todd Huttenstine" but
instead it is "Todd Huttenstine " or cell D206 may have
the value "Randy " instead of "randy". I need these
spaces removed with code because my pivot table is showing
duplicates due to this space. The pivot tables looks at
this as 2 different values because technically the space
makes it that way.

Any help is appreciated.

Todd Huttenstine




All times are GMT +1. The time now is 05:02 AM.

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