Consulting

Results 1 to 3 of 3

Thread: Solved: Extract words

  1. #1

    Solved: Extract words

    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

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Is this what you are after?
    [VBA]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
    Next
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Thank you mdmackillop. From your example, I was able to create a solution to accomplish what I was looking for. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •