Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
STRING MANIPULATION ! !
Thanks, Dave..I never knew the replace() function could take in 5 inputs. Jay *** Sent via Developersdex http://www.developersdex.com *** |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
STRING MANIPULATION !! | Excel Programming | |||
String Manipulation within VBA | Excel Discussion (Misc queries) | |||
Importing Long String - String Manipulation (INVRPT) (EDI EANCOM 96a) | Excel Programming | |||
Importing Long String - String Manipulation (EDI EANCOM 96a) | Excel Programming | |||
String manipulation!! | Excel Programming |