Data inside Cell Seperated by comma

  • Thread starter Thread starter gwoodby
  • Start date Start date
G

gwoodby

Is there any Way to pull data from a cell, then store that in an
array, then split the data and set it in 2 different text boxes??
for instance the name John Monroe
MyString = John, Monroe

TextBox1.text = John
TextBox2.text = Monroe
Im not really sure how to do this, My spreadsheet is already fairly
large, so im trying to hide multiple items inside a s ingle cell now,
MyString will be selected from a combobox, if that helps any :|
 
Is there any Way to pull data from a cell, then store that in an
array, then split the data and set it in 2 different text boxes??
for instance the name John Monroe
MyString = John, Monroe

TextBox1.text = John
TextBox2.text = Monroe
Im not really sure how to do this, My spreadsheet is already fairly
large, so im trying to hide multiple items inside a s ingle cell now,
MyString will be selected from a combobox, if that helps any :|

Versions of Excel after 97 have the "Split" function that should help.

Dim strA as String
Dim strB as String
Dim strC as String
Dim strX as String
Dim vntX as Variant
strX = "a,b,c"
vntX = Split(strX, ",")
strA = vntX(0) ' "a"
strB = vntX(1) ' "b"
strC = vntX(2) ' "c"
 
if you are sure that your values will be seperated by a comma then use the
instr function:

TextBox1.text = left(cbo.value,instr(1, cbo.value,",")-1) 'pulls all text
to the left of the comma

TextBox2.text = right(cbo.value,trim(len(cbo.value) - instr(1,
cbo.value,","))) 'pulls all text to the right of the comma
 
Versions of Excel after 97 have the "Split" function that should help.

Dim strA as String
Dim strB as String
Dim strC as String
Dim strX as String
Dim vntX as Variant
strX = "a,b,c"
vntX = Split(strX, ",")
strA = vntX(0) ' "a"
strB = vntX(1) ' "b"
strC = vntX(2) ' "c"

Ty It works Perfectly!!! I owe you and this form, It has been an
incredible help to me, I appreciate All of you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top