• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to Extract from a List of Comma Separted Text

Hello, I'm new to VBA and have a question. I have searched but cannot find what I'm looking for.


I have a spreadsheet that has text in one column, I need to be able to populate a checkbox based on what is in the cell.


Example: Cell A2 is the COID#, then in cell H2 is a list of services: payroll,tax,401k,HRSC,TLM and so on.


On a UserForm using a MultiPage I have a CheckBox for each service. I am trying to have each CheckBox populate based on what is in the workbook, which is separate from the workbook that contains the macro.


Is it possible to read between the commas?


Thanks for any help.
 
I think you're going to want to use the Split Method. It lets you provide a string and a delimiter, and it then splits that string at the delimiters. Example code:

[pre]
Code:
Sub UseSplit()
Dim StartWord As String
Dim Outputs As Variant

StartWord = "payroll,tax,401k,HRSC,TLM"
Outputs = Split(StartWord, ",")

'Now, to get the different parts, we use numbers like this:
'This section is simply to show how the word has been split up
'note that Outputs now requires a numerical index to indicate
'which one you want to look at
For i = 0 To UBound(Outputs)
Cells(i + 1, "A") = Outputs(i)
Next

End Sub
[/pre]
 
Back
Top