Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default STRING MANIPULATION ! !


Hello !

AA is a variable that contains a string. BB is another string variable.

I need a macro that will create a new string CC which is made by
inserting BB into AA (after the first word in AA).

Example: If AA="They are capable" and BB="think they", then CC should be
"They think they are capable." Any help would be apreciated!

Thanks
Jay


*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default STRING MANIPULATION ! !

You say you want a "macro", but the description of what you are looking for
is not a macro (another name for subroutine without arguments), so I'm not
totally sure how to answer your question. Here is code that will produce the
result you want in a variable named CC (we can dress it up as a function or
subroutine depending on what you might want, but you will have to clarify
that part for us)...

Dim AA As String, BB As String, CC As String
Dim Words() As String
AA = "They are capable"
BB = "think they"
Words = Split(AA)
Words(1) = Words(1) & " " & BB
CC = Join(Words)
MsgBox CC

--
Rick (MVP - Excel)


"jay dean" wrote in message
...

Hello !

AA is a variable that contains a string. BB is another string variable.

I need a macro that will create a new string CC which is made by
inserting BB into AA (after the first word in AA).

Example: If AA="They are capable" and BB="think they", then CC should be
"They think they are capable." Any help would be apreciated!

Thanks
Jay


*** Sent via Developersdex http://www.developersdex.com ***


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default STRING MANIPULATION ! !

Just to add on if you are looking for formula..please try the below in C1
assuming

A1 = "They are capable"
B1 = "think they"

=SUBSTITUTE(A1," ", " " & B1 & " ",1)

If this post helps click Yes
---------------
Jacob Skaria


"jay dean" wrote:


Hello !

AA is a variable that contains a string. BB is another string variable.

I need a macro that will create a new string CC which is made by
inserting BB into AA (after the first word in AA).

Example: If AA="They are capable" and BB="think they", then CC should be
"They think they are capable." Any help would be apreciated!

Thanks
Jay


*** Sent via Developersdex http://www.developersdex.com ***

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default STRING MANIPULATION ! !

Another one:

Option Explicit
Sub testme()

Dim AA As String
Dim BB As String
Dim CC As String

AA = "They are capable"
BB = "think they"

If InStr(1, AA, " ", vbTextCompare) 0 Then
CC = Replace(AA, " ", " " & BB & " ", 1, 1, vbTextCompare)
End If

MsgBox CC

End Sub



jay dean wrote:

Hello !

AA is a variable that contains a string. BB is another string variable.

I need a macro that will create a new string CC which is made by
inserting BB into AA (after the first word in AA).

Example: If AA="They are capable" and BB="think they", then CC should be
"They think they are capable." Any help would be apreciated!

Thanks
Jay

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 154
Default STRING MANIPULATION ! !


Thanks, Dave..I never knew the replace() function could take in 5
inputs.

Jay


*** Sent via Developersdex http://www.developersdex.com ***


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default STRING MANIPULATION ! !

VBA's help is nice <vbg.

jay dean wrote:

Thanks, Dave..I never knew the replace() function could take in 5
inputs.

Jay

*** Sent via Developersdex http://www.developersdex.com ***


--

Dave Peterson
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
STRING MANIPULATION !! jay dean Excel Programming 1 April 27th 09 10:43 AM
String Manipulation within VBA BillCPA Excel Discussion (Misc queries) 2 December 6th 06 05:29 PM
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) Brian Excel Programming 3 February 9th 06 03:38 PM
Importing Long String - String Manipulation (EDI EANCOM 96a) Brian Excel Programming 6 February 9th 06 12:27 PM
String manipulation!! Mannyluk Excel Programming 2 October 18th 04 12:42 PM


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