Consulting

Results 1 to 4 of 4

Thread: Splitting the name of dropdown

  1. #1

    Splitting the name of dropdown

    Hi,
    Assume I have a dropdown by name : Module:drp:B5.
    I need to split this string and get the value as B.Kindly provide some suggestions to i arrive at a solution for this problem.
    Regards
    Vidya

  2. #2
    VBAX Contributor
    Joined
    May 2010
    Location
    Sydney, NSW, Australia
    Posts
    170
    Location
    It's ugly but this works:

    left(right(": Module:drp:B5",len(": Module:drp:B5")-instr(instr(instr(1,": Module:drp:B5",":")+1,": Module:drp:B5",":")+1,": Module:drp:B5",":")),1)
    Returns the first character after the third :
    Last edited by Aussiebear; 04-13-2023 at 12:31 PM. Reason: Adjusted the code tags

  3. #3
    VBAX Contributor
    Joined
    May 2010
    Location
    Sydney, NSW, Australia
    Posts
    170
    Location
    This is a much more elegant way of doing it and it doesn't matter how many : you have:

    Sub SplitString()
    Dim MyArr As Variant
    Dim MyString As String
    Dim MyNewString As String
    MyString = ": Module:drp:B5"
    MyArr = Split(MyString, ":")
    MyNewString = Left(MyArr(UBound(MyArr)), 1)
    msgbox MyNewString
    End Sub
    Last edited by Aussiebear; 04-13-2023 at 12:32 PM. Reason: Adjusted the code tags

  4. #4

    Solved : Splitting the name of dropdown

    Hi,
    Thanks a lot. It worked perfectly.

    Regards
    Vidya

Posting Permissions

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