View Full Version : Solved: Extract words

01-19-2012, 11:16 AM
Each sheet tab has a the following format...Name (2012)

I have a userform that has to combo boxes...cboName & cboYear

I would like to display....
- only the name in the cboName from the sheet tab
- only the year (without the parenthesis) in the cboYear from the sheet tab

Can someone assist. Thanks

01-19-2012, 11:38 AM
Is this what you are after?
Private Sub UserForm_Initialize()
Dim txt As String, sh As Worksheet

For Each sh In Sheets
ComboBox1.AddItem Trim(Split(sh.Name, "(")(0))
txt = Trim(Split(sh.Name, "(")(1))
txt = Left(txt, Len(txt) - 1)
ComboBox2.AddItem txt
End Sub

01-19-2012, 11:55 AM
Thank you mdmackillop. From your example, I was able to create a solution to accomplish what I was looking for. Thank you.