Results 1 to 3 of 3

Thread: [RESOLVED] Find specific data in sheet name

Hybrid View

  1. #1
    Fanatic Member VBAhack's Avatar
    Join Date
    Dec 2004
    Location
    Sector 000
    Posts
    617

    Re: Find specific data in sheet name

    If the name always has 3 parts separated by a single space between the parts, the following should work:

    VB Code:
    1. Dim Array1() As String
    2.     Dim shName As String
    3.     shName = "XXX YYY ZZZ"
    4.     Array1 = Split(shName, Chr$(32))
    5.     Debug.Print Array1(2) 'contains ZZZ

    Here's another option:

    VB Code:
    1. Dim shName As String, Name2 As String, Name3 As String
    2.     shName = "XXX YYY ZZZ"
    3.     Name2 = Mid$(shName, 1 + InStr(shName, Chr$(32)))
    4.     Name3 = Mid$(Name2, 1 + InStr(Name2, Chr$(32)))
    5.     Debug.Print Name3

    Option #3:

    VB Code:
    1. Dim str1 As String
    2.     str1 = "XXX YYY ZZZ"
    3.     Debug.Print Mid(str1, WorksheetFunction.Find(Chr$(32), str1, 1 + InStr(str1, Chr$(32)) + 1))
    Last edited by VBAhack; Apr 20th, 2006 at 11:14 PM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Location
    Montreal, Canada
    Posts
    152

    Re: Find specific data in sheet name

    Thanks a lot VBAhack

    really helpful what you gave me

Posting Permissions

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



Click Here to Expand Forum to Full Width