#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 70
Default space in word

i want the space between word, i used the following VB Code, But its not work.

When i run the VB code, i get word seperated from number, but there is no
space between word.
what i have to make changes in VB Code.
I am really thankful to Gord Dibben MS Excel MVP.
again help expected

Sub RemoveNumbers()
' Remove alpha characters from a string.
' except for decimal points and hyphens.
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[a-z]" Then
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default space in word

Hi,

2 very small changes

Else: strNotNum = " "
Now has a space between the quotes

rngR.Value = WorksheetFunction.Trim(strTemp)
To get rid of leading spaces.

Sub RemoveNumbers()
' Remove alpha characters from a string.
' except for decimal points and hyphens.
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[a-z]" Then
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = " "
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = WorksheetFunction.Trim(strTemp)
Next rngR

End Sub

Mike

"hitesh" wrote:

i want the space between word, i used the following VB Code, But its not work.

When i run the VB code, i get word seperated from number, but there is no
space between word.
what i have to make changes in VB Code.
I am really thankful to Gord Dibben MS Excel MVP.
again help expected

Sub RemoveNumbers()
' Remove alpha characters from a string.
' except for decimal points and hyphens.
Dim intI As Integer
Dim rngR As Range, rngRR As Range
Dim strNotNum As String, strTemp As String

Set rngRR = Selection.SpecialCells(xlCellTypeConstants, _
xlTextValues)

For Each rngR In rngRR
strTemp = ""
For intI = 1 To Len(rngR.Value)
If Mid(rngR.Value, intI, 1) Like "[a-z]" Then
strNotNum = Mid(rngR.Value, intI, 1)
Else: strNotNum = ""
End If
strTemp = strTemp & strNotNum
Next intI
rngR.Value = strTemp
Next rngR

End Sub

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
Delete space after word Niniel Excel Discussion (Misc queries) 14 June 26th 11 04:34 PM
Can I automatically add space after ea. row ("Space After" in Word Reddheddz Excel Discussion (Misc queries) 0 June 17th 08 05:55 PM
When added to the end of one word the space bar changes the word Martha at Walkers Excel Discussion (Misc queries) 1 September 25th 07 07:49 PM
Word: replace ... ... with space Birdtoes Excel Discussion (Misc queries) 1 February 25th 05 03:44 PM
How do I clear blank space at the top of a word-wrapped text cell? mirage1210 Excel Discussion (Misc queries) 2 February 11th 05 09:19 PM


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

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"