String Parsing

airforceone

Board Regular
Joined
Feb 14, 2022
Messages
177
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
00000 TEMPLATE.xlsx
ABCD
1Copied EntryExpected Result
2Dog*Brown,White,Black,Dragon*Golden,Green,Red,Black,Panda*Red,Black,GreenDog*Brown,White,BlackDragon*Golden,Green,Red,BlackPanda*Red,Black,Green
Sheet1 (2)

As shown above I would like to parse the cell value for every "*" entry to arrive at the expected result, below is my somewhat working code :)
Number of Pet may go up as many as 8 sets, in the above example we have 3 Pet Sets ie. Dog, Dragon and Panda.
VBA Code:
Sub ListOfAnimals()
    Dim aPets() As String
    Dim iCTR As Long
    aPets = Split(Cells(2, 1), "*")
    For iCTR = LBound(aPets) To UBound(aPets)
        Debug.Print aPets(iCTR)
    Next
End Sub
 
You have placed the code in a different location to that suggested. Try it, as indicated, in a module in the workbook where it will be used, not in your personal macro workbook.
Oh My! Fault accepted! thanks mate, It's working now.
I'll try to find a remedy to parse it more, since there are 3 sets of animals in the string.
The code seems to just parse the first occurrence...
 
Upvote 0

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,215,432
Messages
6,124,858
Members
449,194
Latest member
HellScout

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top