Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro to remove blanks in text


Hi all,
I have text in cell C11 to C5000.
Do anyone know a macro that will remove the blank in the text?
Ta


--
herve
------------------------------------------------------------------------
herve's Profile: http://www.excelforum.com/member.php...o&userid=27314
View this thread: http://www.excelforum.com/showthread...hreadid=473029

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Macro to remove blanks in text


"herve" schrieb im
Newsbeitrag ...

Hi all,
I have text in cell C11 to C5000.
Do anyone know a macro that will remove the blank in the text?
Ta


--
herve
------------------------------------------------------------------------


herve,

it would be helpful if you could be more specific - trailing or leading
blanks, blanks in the middle of text, shall the blanks be completely removed
or shall mutiple blanks be replaced by one ....

Stephan


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Macro to remove blanks in text

Hi Herve,
How about
Sub Del_spaces()
Range("C11:C5000").Select
Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End Sub
I think that should do what you are looking for.
Terry

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Macro to remove blanks in text

I use two - one to remove blank spaces - and another to completely remove any
hanging spaces at the end of cells (useful after a SQL data pull)
================
Sub Trim_all_blanks_in_cells()
'Trims all blank spaces appended to the end of text in cell values
'Useful when importing text which leaves blank characters in the
'cells. For eliminating *any* spaces on the cells, use a find/replace
'as detailed below in 'eliminate_spaces_in_cell_text'

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim Cell As Range
'Also Treat CHR 0160, as a space (CHR 032)
Selection.Replace What:=Chr(160), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
'Trim in Excel removes extra internal spaces, VBA does not
On Error Resume Next 'in case no text cells in selection
For Each Cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
Cell.Value = Application.Trim(Cell.Value)
Next Cell
On Error GoTo 0
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub




Sub eliminate_spaces_in_cell_text()

'**** Add a selection statement here <Columns("E:E").Select,
'**** <Range("A1).Select, etc

Selection.Replace What:=" ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False

End Sub
================

"herve" wrote:


Hi all,
I have text in cell C11 to C5000.
Do anyone know a macro that will remove the blank in the text?
Ta


--
herve
------------------------------------------------------------------------
herve's Profile: http://www.excelforum.com/member.php...o&userid=27314
View this thread: http://www.excelforum.com/showthread...hreadid=473029


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Macro to remove blanks in text

here's another way

Sub RemoveSpaces()

Worksheets("Sheet3").Range("c11:c500").Replace _
What:=" ", Replacement:="", _
SearchOrder:=xlByColumns, MatchCase:=True

End Sub

--


Gary


"herve" wrote in
message ...

Hi all,
I have text in cell C11 to C5000.
Do anyone know a macro that will remove the blank in the text?
Ta


--
herve
------------------------------------------------------------------------
herve's Profile:
http://www.excelforum.com/member.php...o&userid=27314
View this thread: http://www.excelforum.com/showthread...hreadid=473029



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
remove duplicates except blanks jat Excel Worksheet Functions 2 December 11th 09 12:25 PM
remove blanks using formula Gotroots Excel Worksheet Functions 5 December 9th 09 10:52 AM
Condense list (remove blanks) socram Excel Worksheet Functions 2 March 10th 07 12:27 AM
Concatenate and remove blanks PeterW Excel Worksheet Functions 3 January 19th 06 06:04 PM
Can I remove blanks from a range without using sort? Hugh Murfitt Excel Discussion (Misc queries) 6 March 8th 05 08:37 AM


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

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

About Us

"It's about Microsoft Excel"