How to work with and modify texts (strings) in excel VBA?
- fredrikstaalnacke
- Jan 25, 2021
- 3 min read
Updated: Feb 3, 2021

Strings is just another word for text and in order to write strings you need to use the " quotation signs. This part will go through some practical ways to work with and modify strings to your specification.
We will starting working with the classic analyst phrase. "Please Fix Thx." and modify that one throughout the examples on the page. Let's start with adding the text parts in to three strings.
A = "Please" B = "Fix" C = "Thx."
Below are some examples of your normal text operations
Join strings
We can combine or join strings with the and '&' operator where we can mix variables and texts.
'No spaces
MsgBox (A & B & C)
'With spaces
MsgBox (A & " " & B & " Thx.")Now Let's add them all into one string D for further modifications.
'Let's make sure these are added into one string D.
D = A & " " & B & " Thx."Left Syntax
'Now let's take out the first part ("Please") from D.
MsgBox (Left(D, 6)) Right Syntax
'Let's take out the last part ("Thx.")
MsgBox (Right(D, 4))Mid Syntax
'Middle part can be taken out with the following ("Fix").
'Note here that our 7th character is a space.
'No point of including that, hence why I start at place 8th.
MsgBox (Mid(D, 8, 3))Split Syntax
Split is a practical syntax for dividing a string into multiple ones based on a separator sign.
'Split our text string based on the space.
'The result will be stored in a array containing the 3 text parts we added originally.
MyArray = (Split(D, " "))
Debug.Print MyArray(0) 'Please
Debug.Print MyArray(1) 'Fix
Debug.Print MyArray(2) 'Thx.
'Add (0) for only returning the First textstring back which is "Please"
'Add (1) for the second etc.. just like a normal array.
MsgBox (Split(D, " ")(0)) 'PleaseReplace Syntax
'Replace function
'Replace a character with another one of your choosing.
MsgBox (Replace(D, " ", "-")) 'Please-Fix-Thx.Trim Syntax
'Trim Function
'Removes leading and trailing spaces.
MsgBox (" " & D & " ")
MsgBox (Trim(" " & D & " "))Now in order to test that the trim function worked other than looking at the size of the message boxes is with the Len syntax which gives us the number of characters in the string.
Len Syntax
'Length of string
MsgBox Len((" " & D & " ")) '39 characters.
MsgBox Len((Trim(" " & D & " "))) '15 characters.As we can see, the result was 15 characters instead of the 39 otherwise returned, which means that the Trim function worked like it is supposed to.
Instr Syntax
'Instr function similar to find where you want to find a substring in a string.
'InStr([ start ], string1, string2, [ compare ])
'InStr returns the startingplace for a substring. it is case sensitive.
'Fi from 'Fix' is being found at startingposition 8.
MsgBox (InStr(D, "Fi"))
'Asking my code to start looking from Characterposition 10 in "Please Fix Thx."
'This is returning 0 as the substring "Fi" is not found.
MsgBox (InStr(10, D, "Fi"))LCase Syntax
'To sort out any instr issue of finding a text.
'Use Lcase which converts to Lowercase text.
'Alternatively you can use Ucase to convert to uppercase text.
MsgBox (LCase(D)) 'Lower caseAlternatively we can use UCase if want to convert it to uppercase text instead.
UCase Syntax
MsgBox (UCase(D)) 'Upper caseInstrRev Syntax
'Reverse searching with InstrRev function
'InstrRev(stringcheck, stringmatch, [ start, [ compare ]])
MsgBox (InStrRev(D, "T")) 'returns position 12.



<a href="https://mycopharma.store/product/wegovy-uk/" rel="dofollow">wegovy-uk</a>
<a href="https://mycopharma.store/product/elvanse-for-adhd/" rel="dofollow">elvanse-for-adhd</a>
<a href="https://mycopharma.store/product/nembutal-uk/" rel="dofollow">nembutal-uk</a>
<a href="https://mycopharma.store/product/ambien-uk/" rel="dofollow">ambien-uk</a>
<a href="https://mycopharma.store/product/rohypnol-uk-for-sale-1-2-mg/" rel="dofollow">rohypnol-uk-for-sale-1-2-mg</a>
<a href="https://mycopharma.store/product/vicodin-uk/" rel="dofollow">vicodin-uk</a>
<a href="https://mycopharma.store/product/oxazepam/" rel="dofollow">oxazepam</a>
<a href="https://mycopharma.store/product/ritalin-uk/" rel="dofollow">ritalin-uk</a>
<a href="https://mycopharma.store/product/buy-ozempic-online-uk/" rel="dofollow">buy-ozempic-online-uk</a>
<a href="https://mycopharma.store/product/acxion-fentermina-30-mg/" rel="dofollow">acxion-fentermina-30-mg</a>
<a href="https://mycopharma.store/product/buy-diazepam-uk-next-day-delivery/" rel="dofollow">buy-diazepam-uk-next-day-delivery</a>
<a href="https://mycopharma.store/product/adhd-medication-uk/" rel="dofollow">adhd-medication-uk</a>
<a href="https://mycopharma.store/product/saxenda-uk/" rel="dofollow">saxenda-uk</a>
<a href="https://mycopharma.store/product/stilpane-syrup/" rel="dofollow">stilpane-syrup</a>
<a href="https://mycopharma.store/product/tretinoin-cream-uk/" rel="dofollow">tretinoin-cream-uk</a>
<a href="https://ritalinuk.com/product/flow-neuroscience/" rel="dofollow">flow-neuroscience</a>
<a href="https://ritalinuk.com/product/dexamfetamine/" rel="dofollow">dexamfetamine</a>
<a href="https://ritalinuk.com/product/adderall-uk/" rel="dofollow">adderall-uk</a>
<a href="https://ritalinuk.com/product/ritalin-uk/" rel="dofollow">ritalin-uk</a>
<a href="https://ausmedscenter.com/product/wegovy-australia/" rel="dofollow">wegovy-australia</a>
<a href="https://ausmedscenter.com/product/endone/" rel="dofollow">endone</a>
<a href="https://ausmedscenter.com/product/wegovy-australia-cost/" rel="dofollow">wegovy-australia-cost</a>
<a href="https://ausmedscenter.com/product/ozempic-australia/" rel="dofollow">ozempic-australia</a>
<a href="https://ausmedscenter.com/product-category/weight-loss-medication-australia/" rel="dofollow">weight-loss-medication-australia</a>
<a href="https://ausmedscenter.com/product/oxycodone-5mg/" rel="dofollow">oxycodone-5mg</a>
<a href="https://pharmaceuticalbankuk.com/product/ritalin-10mg/" rel="dofollow">ritalin-10mg</a>
<a href="https://pharmaceuticalbankuk.com/product/buy-xanax-0-25mg/" rel="dofollow">buy-xanax-0-25mg</a>
<a href="https://pharmaceuticalbankuk.com/product/rohypnol-uk/" rel="dofollow">rohypnol-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/oxazepam-uk/" rel="dofollow">oxazepam-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/oxycodone-uk/" rel="dofollow">oxycodone-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/dextroamphetamine-uk/" rel="dofollow">dextroamphetamine-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/oxycontin-uk/" rel="dofollow">oxycontin-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/rybelsus-uk/" rel="dofollow">rybelsus-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/elvanse-uk/" rel="dofollow">elvanse-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/buy-diazepam-uk-next-day-delivery/" rel="dofollow">buy-diazepam-uk-next-day-delivery</a>
<a href="https://pharmaceuticalbankuk.com/product/arimidex-uk/" rel="dofollow">arimidex-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/adderall-uk/" rel="dofollow">adderall-uk</a>
<a href="https://pharmaceuticalbankuk.com/product/farmapram-2mg/" rel="dofollow">farmapram-2mg</a>
<a href="https://lavavapes.com/product-category/lava-flavors/" rel="dofollow">lava-flavors</a>
<a href="https://lavavapes.com/product/lava-vape/" rel="dofollow">lava-vape</a>
<a href="https://medic-apotheke.com/product/adderall/" rel="dofollow">Adderall</a>
<a href="https://medic-apotheke.com/product/alprazolam/"rel="dofollow">Alprazolam</a>
<a href="https://medic-apotheke.com/product/blue-dream/" rel="dofollow">Blue Dream</a>
<a href="https://medic-apotheke.com/product/clonazepam/" rel="dofollow">Clonazepam</a>
<a href="https://medic-apotheke.com/product/granddaddy-purple/" rel="dofollow">Granddaddy Purple</a>
<a href="https://medic-apotheke.com/product/kush/" rel="dofollow">Kush</a>
<a href="https://medic-apotheke.com/product/lorazepam/" rel="dofollow">Lorazepam</a>
<a href="https://medic-apotheke.com/product/midazolam/" rel="dofollow">Midazolam</a>
<a href="https://medic-apotheke.com/product/nembutal/" rel="dofollow">Nembutal</a>
<a href="https://medic-apotheke.com/product/sour-diesel/" rel="dofollow">Sour Diesel</a>
<a href="https://medic-apotheke.com/product/xanax/" rel="dofollow">Xanax</a>
<a href="https://medic-apotheke.com/product/danazol/" rel="dofollow">Danazol</a>
<a href="https://medic-apotheke.com/product/mesterolone/" rel="dofollow">Mesterolone</a>
<a href="https://medic-apotheke.com/product/methyl-testosterone/" rel="dofollow">Methyl Testosterone</a>
<a href="https://medic-apotheke.com/product/oxandrolone/" rel="dofollow">Oxandrolone</a>
<a href="https://medic-apotheke.com/product/nandrolone/" rel="dofollow">Nandrolone</a>
<a href="https://medic-apotheke.com/product/testosteron-kapseln/" rel="dofollow">Testosteron Kapseln</a>
<a href="https://medic-apotheke.com/product/elvanse/" rel="dofollow">Elvanse</a>
<a href="https://medic-apotheke.com/product/opana/" rel="dofollow">Opana 20mg</a>
<a href="https://medic-apotheke.com/product/oxycontin/" rel="dofollow">Oxycontin</a>
<a href="https://medic-apotheke.com/product/oxynorm/" rel="dofollow">Oxynorm</a>
<a href="https://medic-apotheke.com/product/rohypnol/" rel="dofollow">Rohypnol<a>
<a href="https://medic-apotheke.com/product/sobril/" rel="dofollow">Sobril</a>
<a href="https://medic-apotheke.com/product/suboxone/" rel="dofollow">Suboxone</a>
<a href="https://medic-apotheke.com/product/subutex/" rel="dofollow">Subutex</a>
<a href="https://alohaherbals.com/product/mdma/" rel="dofollow">Mdma Kristal</a>
<a href="https://medic-apotheke.com/product/vicodine/" rel="dofollow">Vicodine</a>
<a href="https://medic-apotheke.com/product/berry-kush/" rel="dofollow">Berry Kush</a>
<a href="https://medic-apotheke.com/product/blackberry-kush/" rel="dofollow">BlackBerry Kush</a>
<a href="https://medic-apotheke.com/product/buprenorphine/" rel="dofollow">Buprenorphine</a>
<a href="https://medic-apotheke.com/product/chaga-pilze/" rel="dofollow">Chaga-Pilze</a>
<a href="https://medic-apotheke.com/product/codeine/" rel="dofollow">Codeine</a>
<a href="https://medic-apotheke.com/product/cordyceps/" rel="dofollow">Cordyceps</a>
<a href="https://medic-apotheke.com/product/fentanyl/" rel="dofollow">Fentanyl</a>
<a href="https://medic-apotheke.com/product/herijuana/" rel="dofollow">Herijuana</a>
<a href="https://medic-apotheke.com/product/hindu-kush/" rel="dofollow">Hindu kush</a>
<a href="https://medic-apotheke.com/product/igelstachelbart-pilze/" rel="dofollow">Igelstachelbart-Pilze</a>
PASCOL4D
PASCOL4D
PASCOL4D
PASCOL4D
PASCOL4D
PASCOL4D
PASCOL4D
<a href="https://parrotsuae.com/product/green-wing-macaw/" rel="dofollow">Green wing macaw</a><a href="https://parrotsuae.com/product/cockatiels/" rel="dofollow">Cockatiels</a><a href="https://parrotsuae.com/product/conure/" rel="dofollow">Black capped conure</a><a href="https://parrotsuae.com/product/crimson-conure/" rel="dofollow">Crimson bellied conure</a><a href="https://parrotsuae.com/product/bronze-winged-pionus-parrot/" rel="dofollow">Bronze winged pionus</a><a href="https://parrotsuae.com/product/cockatoo/" rel="dofollow">Sulphur crested cockatoo</a><a href="https://parrotsuae.com/product/umbrella-cockatoo-2/" rel="dofollow">Umbrella cockatoo</a><a href="https://parrotsuae.com/product/black-palm-cockatoo/" rel="dofollow">Black palm cockatoo</a><a href="https://parrotsuae.com/product/congo-african-grey-for-sale/" rel="dofollow">Congo African</a><a href="https://parrotsuae.com/product/scarlet-macaw-for-sale/" rel="dofollow">Scarlet Macaw</a><a href="https://parrotsuae.com/product/hyacinth-macaw-price/" rel="dofollow">hyacinth-macaw</a><a href="https://parrotsuae.com/product/blue-headed-pionus/" rel="dofollow">blue-headed-pionus</a><a href="https://parrotsuae.com/product/moluccan-cockatoo-for-sale/" rel="dofollow">moluccan-cockatoo</a><a href="https://parrotsuae.com/product/sun-conure-price/" rel="dofollow">sun-conure</a><a href="https://parrotsuae.com/product/macaw-parrot-price-in-uae/" rel="dofollow">macaw-parrot</a><a href="https://parrotsuae.com/product/budgie-parrot/" rel="dofollow">Budgie</a><a href="https://parrotsuae.com/product/double-yellow-headed-amazon/" rel="dofollow">Double yellow headed Amazon</a>
<a
<a href="https://petsnowuae.com/product/american-bully-puppy/" rel="dofollow">American Bully</a><a href="https://petsnowuae.com/product/german-shepherd-puppy/" rel="dofollow">German shepherd puppies</a><a href="https://petsnowuae.com/product/labrador-retriever-puppies/" rel="dofollow">Labrador Retriever</a><a href="https://petsnowuae.com/product/english-mastiff-puppies/" rel="dofollow">English Mastiff</a><a href="https://petsnowuae.com/product/presa-canario/" rel="dofollow">perro de presa canario</a><a href="https://petsnowuae.com/product/teacup-pomeranian-%d9%84%d9%84%d8%a8%d9%8a%d8%b9/" rel="dofollow">Roxie</a><a href="https://petsnowuae.com/product/teacup-pomeranian/" rel="dofollow">Teddy</a><a href="https://petsnowuae.com/product/teacup-pomeranian-for-sale/" rel="dofollow">Silky</a><a href="https://petsnowuae.com/product/white-teacup-pomeranian/" rel="dofollow">Sam</a><a href="https://petsnowuae.com/product/golden-retriever-puppy/" rel="dofollow">Sherlock Holmes</a><a href="https://petsnowuae.com/product/golden-retriever-puppies/" rel="dofollow">Stan</a><a href="https://petsnowuae.com/product/golden-retriever-puppies-for-sale/" rel="dofollow">Stella</a><a href="https://petsnowuae.com/product/shih-tzu-puppies/" rel="dofollow">Maya</a><a href="https://petsnowuae.com/product/shih-tzu-puppy/" rel="dofollow">Lilly</a><a href="https://petsnowuae.com/product/pomeranian-%d9%84%d9%84%d8%a8%d9%8a%d8%b9/" rel="dofollow">Stumpy</a><a href="https://petsnowuae.com/product/cavalier-king-charles-spaniel-for-sale/" rel="dofollow">Jamie</a><a href="https://petsnowuae.com/product/cavalier-king-charles-spaniel-puppy/" rel="dofollow">Gin</a><a href="https://petsnowuae.com/product/buy-cavalier-king-charles-puppies/" rel="dofollow">Cayson</a><a href="https://petsnowuae.com/product/buy-pomeranian-puppy-online/" rel="dofollow">Blake</a>
<a href="https://exoticmonkeybreeders.com/product/capuchin-monkey/" rel="dofollow">Buy Cavan online</a><a href="https://exoticmonkeybreeders.com/product/capuchin/" rel="dofollow">MASOOD</a><a href="https://exoticmonkeybreeders.com/product/capuchin-monkey-for-sale-in-uae-2/" rel="dofollow">Baby Milo Capuchin Monkey online UAE</a><a href="https://exoticmonkeybreeders.com/product/capuchin-monkey-for-sale/" rel="dofollow">IHSAN</a><a href="https://exoticmonkeybreeders.com/product/squirrel-monkey/" rel="dofollow">SNOBAR</a><a…
جلب الحبيب
الحصول على باك لينك قوى لموقعك من خلال تبادل اعلانى نصى
معنا عبر004917637777797 الواتس اب
شيخ روحاني
جلب الحبيب
Berlinintim
Berlin Intim
https://www.eljnoub.com/
https://hurenberlin.com/
شيخ روحاني في برلين 00491634511222
شيخ روحاني
رقم شيخ روحاني
رقم شيخ روحاني
شيخ روحاني في برلين
رقم شيخ روحاني 00491634511222
الشيخ الروحاني
شيخ روحاني سعودي
شيخ روحاني في برلين 00491634511222
Berlinintim
bestbacklinks
backlinkservices
buybacklink
Berlinintim
Escort Berlin
شيخ روحاني
معالج روحاني
الشيخ الروحاني
الشيخ الروحاني
جلب الحبيب العنيد
جلب الحبيب بسرعة
شيخ روحاني الاردن
شيخ روحاني عماني
شيخ روحاني سعودي
شيخ روحاني مضمون
شيخ روحاني مضمون
معالج روحاني سعودي
شيخ روحاني مغربي
شيخ روحاني في قطر
شيخ روحاني لجلب الحبيب
شيخ روحاتي في السعودية
شيخ روحاني في البحرين
شيخ روحاني في الكويت
شيخ…