Can I use UBound for delimited cells?

USAMax

Well-known Member
Joined
May 31, 2006
Messages
846
Office Version
  1. 365
Platform
  1. Windows
I can do this but it would be long than it should be.

Each cell is semi-colon delimited and I could change it to a comma or anything. The problem is that the child must have all the same properties as the parent plus the values of the child and I thought a UBound would work. like this:

Code:
For x = 0 To UBound(Cells(CurRow, OptCol))
IsMatch = False
For y = 0 To UBound(Cells(TmpRow, OptCol))
If x = y Then IsMatch = True
Next y
Next x

Here is sample data:


Samples:
Parent: MOTOPATCH; CD
Child: MOTOPATCH
Desired Result for Child: MOTOPATCH; CD

Parent: ATR
Child: SSC; SA
Desired Result for Child: ATR; SSC; SA

Parent: EEPROM; MOTOPATCH; CD
Child: MOTOPATCH
Desired Result for Child: EEPROM; MOTOPATCH; CD


Thank you,
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Your code is returning Boolean values, but your sample looks like you are trying to return all the unique items from Parent and Child. What are you trying to do exactly? I'm guessing that the Parent and Child text is not part of the value in the cell but the column heading?
 
Upvote 0
Hello Scott:

In the sample data the Parent and Child are both cells on a form. The Desired Results is how the Child cell should look after it is complete. I do not have much experience with UBound but it is what I thought I should use.
 
Upvote 0
I think this may be what you want:

Code:
Function CombineUnique(r As Range) As String
Dim b, c, d, s As String
With CreateObject("scripting.dictionary")
    For Each c In r
        d = Split(c, ";")
            For Each b In d
                b = Trim(b)
                If Not .exists(b) Then
                    .Add b, 1
                    s = s & b & "; "
                End If
             Next
    Next
End With
If Len(s) Then CombineUnique = Left(s, Len(s) - 2)
End Function
Excel Workbook
ABC
1MOTOPATCH; CDMOTOPATCHMOTOPATCH; CD
2ATRSSC; SAATR; SSC; SA
3EEPROM; MOTOPATCH; CDMOTOPATCHEEPROM; MOTOPATCH; CD
Sheet1
 
Upvote 0
Unbelievable job Scott, I had it almost working then I broke them up into an array with half the lines and you have half the lines I ended up with. I have never used Split but it is in my repertoire now!

Thank you,
 
Upvote 0

Forum statistics

Threads
1,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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