Pull string from in between characters (1 Viewer)

berkdad

New member
Local time
Today, 08:11
Joined
Jan 21, 2020
Messages
3
Anyone know an easy way to pull these colors out separately? There isn't always 5 colors. could be two and sometimes even 7 colors in one string. But they will always be separated by "|".

Orange|Yellow|Blue|Violet|Copper

Thanks in advance
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:11
Joined
Jan 23, 2006
Messages
15,379
Suggest Split()
Here's a demo of the Split function

Code:
Sub showSplit()
    Dim x As String
    Dim i As Integer
    Dim vArr As Variant
    x = "Orange|Yellow|Blue|Violet|Copper"
    vArr = Split(x, "|")
    For i = LBound(vArr) To UBound(vArr)
        Debug.Print vArr(i)
    Next
End Sub

Result:

Orange
Yellow
Blue
Violet
Copper

Good luck.


OOoops: minty is too quick.
 

berkdad

New member
Local time
Today, 08:11
Joined
Jan 21, 2020
Messages
3
Suggest Split()
Here's a demo of the Split function

Code:
Sub showSplit()
    Dim x As String
    Dim i As Integer
    Dim vArr As Variant
    x = "Orange|Yellow|Blue|Violet|Copper"
    vArr = Split(x, "|")
    For i = LBound(vArr) To UBound(vArr)
        Debug.Print vArr(i)
    Next
End Sub

Result:

Orange
Yellow
Blue
Violet
Copper

Good luck.


OOoops: minty is too quick.

Awesome, thank you. You're not for hire are you? Working on a small project with a bunch of logic and parameters.
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:11
Joined
Jan 23, 2006
Messages
15,379
Not for hire, but the forum will help if you post clear questions and give an honest effort.
 

isladogs

MVP / VIP
Local time
Today, 16:11
Joined
Jan 14, 2017
Messages
18,209
Hi Minty.
I'm fine thanks. Hope all is good in your new job.
It took me a long time to realise that simple workaround but I'm happy to accept the 'accolade'.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:11
Joined
Oct 29, 2018
Messages
21,449
Hi berkdad. Welcome to AWF!

If you're looking for someone to hire, maybe I could help you. Please send me an email (link below) if you want to discuss it as a possible option for you.

Cheers!
 

berkdad

New member
Local time
Today, 08:11
Joined
Jan 21, 2020
Messages
3
Hi berkdad. Welcome to AWF!

If you're looking for someone to hire, maybe I could help you. Please send me an email (link below) if you want to discuss it as a possible option for you.

Cheers!

looks like i need 10 posts in order to see links and attachments. This is my 3rd. I've actually been a member on here before and have a bunch of posts but it's been a while and not sure what email I used, so i created a new account. Not sure if it's appropriate for me to post my email. If so, i will. Let me know
 

Users who are viewing this thread

Top Bottom