How to pass a Textbox value of any word/sentence (e.g. "Apple" or "Apple is a fruit.") and split it into different cells in a row?

sunilhaokha

New Member
Joined
Aug 10, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Hi everyone, I have been trying to solve this Excel VBA code. Please help me!

Question: How to pass a Textbox value of any word/sentence (e.g. "Apple" or "Apple is a fruit.") and split it into different cells in a row with single letter each in the cell from the value including the spaces or period (say result for the word "Apple" should be - A1 ="A", A2 ="p", A3="p", A4="l" A5="e" or for the sentence "Apple is a fruit." should be - A1 ="A", A2 ="p", A3="p", A4="l" A5="e", A6=" ", A7="i", A8="s", A9=" ", A10="a", A11=" ", A12="f", A13="r", A14="u", A15="i", A16="t", A17=".")? Here I am taking just the examples. The TextBox Value can be anything and cell in a sheet can be in any row.
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Give this code a try in whatever procedure you are using (change the YourTextBoxName stand-in text below to the actual name of your TextBox)...
Rich (BB code):
  Dim Arr As Variant
  Arr = Split(StrConv(YourTextBoxName.Text, vbUnicode), Chr(0))
  Range("B1").Resize(, UBound(Arr) + 1) = Arr
 
Upvote 0
Solution
Give this code a try in whatever procedure you are using (change the YourTextBoxName stand-in text below to the actual name of your TextBox)...
Rich (BB code):
  Dim Arr As Variant
  Arr = Split(StrConv(YourTextBoxName.Text, vbUnicode), Chr(0))
  Range("B1").Resize(, UBound(Arr) + 1) = Arr
Thank you Rick Rothstein. These lines works well.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top