Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to change words in excel cells?

I have a group of cells filled with words in excel. I need to put a
space after the 3rd charactor in each word. How can i do it using VBA?
thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default How to change words in excel cells?

Does each cell have one word or more than one? In other words, how
many spaces do you want to insert?

If only one word in a cell, then:

Sub macro1()
Dim rng As Range
Dim c As Range
Set rng = Sheets("Sheet1").Range("A1:A6")
For Each c In rng
c = Left(c, 3) & " " & Right(c, Len(c) - 3)
Next c
End Sub

Hth,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default How to change words in excel cells?

On Feb 6, 9:03 pm, "Jerry" wrote:
I have a group of cells filled with words in excel. I need to put a
space after the 3rd charactor in each word. How can i do it using VBA?
thanks


Does each cell you want 'fixed' contain only one word, or are there
multiple words in each cell that you want fixed.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to change words in excel cells?

Thank you very much! it is exactly what I want

merjet wrote:
Does each cell have one word or more than one? In other words, how
many spaces do you want to insert?

If only one word in a cell, then:

Sub macro1()
Dim rng As Range
Dim c As Range
Set rng = Sheets("Sheet1").Range("A1:A6")
For Each c In rng
c = Left(c, 3) & " " & Right(c, Len(c) - 3)
Next c
End Sub

Hth,
Merjet


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to change words in excel cells?

On Feb 6, 10:20 pm, "okrob" wrote:
On Feb 6, 9:03 pm, "Jerry" wrote:

I have a group of cells filled with words in excel. I need to put a
space after the 3rd charactor in each word. How can i do it using VBA?
thanks


Does each cell you want 'fixed' contain only one word, or are there
multiple words in each cell that you want fixed.



i simplified my problem. Each cell contains fixed length word. I need
to insert spaces into couple of places (fixed positions)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default How to change words in excel cells?

Jerry,
Maybe you can adapt this:

Public Function InsertChars(argWord As String, CharsToInsert As String,
ParamArray AtPositions() As Variant) As String
Dim i As Long
Dim Temp As String
Dim LastPos As Long

LastPos = 1
For i = LBound(AtPositions) To UBound(AtPositions)
Temp = Temp & Mid(argWord, LastPos, AtPositions(i) - LastPos) &
CharsToInsert
LastPos = AtPositions(i)
Next

InsertChars = Temp & Right(argWord, Len(argWord) -
AtPositions(UBound(AtPositions)) + 1)
End Function

And call it with
=InsertChars("LongWordNeedsCharsInserted","@",5,9, 14,19)
Long@Word@Needs@Chars@Inserted


NickHK

"Jerry" wrote in message
ups.com...
On Feb 6, 10:20 pm, "okrob" wrote:
On Feb 6, 9:03 pm, "Jerry" wrote:

I have a group of cells filled with words in excel. I need to put a
space after the 3rd charactor in each word. How can i do it using VBA?
thanks


Does each cell you want 'fixed' contain only one word, or are there
multiple words in each cell that you want fixed.



i simplified my problem. Each cell contains fixed length word. I need
to insert spaces into couple of places (fixed positions)



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default How to change words in excel cells?

Thanks, very nice function. Saved for future use. Thanks again

On Feb 7, 12:37 am, "NickHK" wrote:
Jerry,
Maybe you can adapt this:

Public Function InsertChars(argWord As String, CharsToInsert As String,
ParamArray AtPositions() As Variant) As String
Dim i As Long
Dim Temp As String
Dim LastPos As Long

LastPos = 1
For i = LBound(AtPositions) To UBound(AtPositions)
Temp = Temp & Mid(argWord, LastPos, AtPositions(i) - LastPos) &
CharsToInsert
LastPos = AtPositions(i)
Next

InsertChars = Temp & Right(argWord, Len(argWord) -
AtPositions(UBound(AtPositions)) + 1)
End Function

And call it with
=InsertChars("LongWordNeedsCharsInserted","@",5,9, 14,19)

Long@Word@Needs@Chars@Inserted


NickHK

"Jerry" wrote in message

ups.com...



On Feb 6, 10:20 pm, "okrob" wrote:
On Feb 6, 9:03 pm, "Jerry" wrote:


I have a group of cells filled with words in excel. I need to put a
space after the 3rd charactor in each word. How can i do it using VBA?
thanks


Does each cell you want 'fixed' contain only one word, or are there
multiple words in each cell that you want fixed.


i simplified my problem. Each cell contains fixed length word. I need
to insert spaces into couple of places (fixed positions)- Hide quoted text -


- Show quoted text -



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
How do I change the y-axis on an Excel chart from numbers to words WDGILBERT Charts and Charting in Excel 6 September 16th 09 09:27 PM
How do I change automatically figures into words in Excel Mohammed Shabir Excel Worksheet Functions 1 November 13th 06 08:58 AM
How can we change linked numbers to words in Excel? Dheeraj Agarwal Excel Programming 1 October 27th 06 11:39 AM
In Excel, how do I change Column Hdings to words not A, B? Pam L. Excel Programming 1 September 12th 05 09:13 PM
How can I change Numbers in WOrds in Excel A J Excel Discussion (Misc queries) 3 May 9th 05 08:14 AM


All times are GMT +1. The time now is 03:36 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"