Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2
Default Trailing Spaces in Merged Cells

Hi,

I have a large spreadsheet with data in merged cells. When I look in Excel,
the trailing spaces doesn't appear and when I copied the data onto Notepad,
the spaces are shown. I have tried TRIM (works for single cells not merged
cells). Any help would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 293
Default Trailing Spaces in Merged Cells

Hi Meng,

Try the following macro:

Sub TrimRange()
Dim SBar As Boolean, Cell As Range, CellCount As Long, I As Long
SBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
Application.ScreenUpdating = False
Application.Calculation = xlManual
On Error Resume Next
I = 0
If Selection.Rows.Count * Selection.Columns.Count 1 Then
CellCount = Selection.Rows.Count * Selection.Columns.Count
Else
CellCount = ActiveSheet.UsedRange.Rows.Count * ActiveSheet.UsedRange.Columns.Count
End If
For Each Cell In Selection.SpecialCells(xlConstants)
Cell.Value = Application.Trim(Replace(Cell.Value, Chr(160), " "))
I = I + 1
Application.StatusBar = Int(I / CellCount * 100 + 0.5) & "% Trimmed"
Next Cell
Application.Calculation = xlAutomatic
Application.StatusBar = False
Application.DisplayStatusBar = SBar
Application.ScreenUpdating = True
MsgBox "Finished trimming " & CellCount & " cells.", 64
End Sub

--
Cheers
macropod
[Microsoft MVP - Word]


"Meng" wrote in message ...
Hi,

I have a large spreadsheet with data in merged cells. When I look in Excel,
the trailing spaces doesn't appear and when I copied the data onto Notepad,
the spaces are shown. I have tried TRIM (works for single cells not merged
cells). Any help would be greatly appreciated.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unwanted spaces in merged cells ksf Excel Discussion (Misc queries) 1 April 22nd 09 03:08 AM
trailing spaces peter Excel Worksheet Functions 3 October 18th 07 11:32 PM
REMOVING TRAILING SPACES Tris Excel Discussion (Misc queries) 5 August 29th 06 03:36 PM
remove trailing spaces les8 Excel Discussion (Misc queries) 4 January 20th 06 03:55 PM
Removing trailing spaces from cells ? Don Guillett Excel Worksheet Functions 0 April 10th 05 03:32 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"