Formula to Copy

SIBYCHERIAN

New Member
Joined
Mar 31, 2006
Messages
30
Hi I need a formula for the following ...there are 4 columns PC5,Product Code, Sample and I need a formula in the options column...

PC5 Product Code SAMPLE Options
63612 63612-0037 20
63612 63612-0038 0
63612 63612-0041 0
U6002 U6002-0012 0
U6002 U6002-0013 0
U6002 U6002-0016 20
U6002 U6002-0017 0

In the table above Under the options column , Wherever there is 20 under the samples column, In the options Column,I want all the other Product codes with the same PC5 ....meaning...I need the below output.

PC5 Product Code SAMPLE Options
63612 63612-0037 20 63612-0038,63612-0041
63612 63612-0038 0 0
63612 63612-0041 0 0
U6002 U6002-0012 0 0
U6002 U6002-0013 0 0
U6002 U6002-0016 20 U6002-0012,U6002-0013,U6002-0017
U6002 U6002-0017 0 0


Is there a formula for doing the same.
 
Hi ,

Im trying to do the below mentioned function ,but when I copy the formula on the cell after saving the macro I get the result #NAME?...can you plz help.



Maybe an alternate non-array function will help. Mike Rickson from here on MrExcel posted a new string concatenation UDF the other day that is more compact and doesn't require array confirmation. Here's the code:
Code:
Function ConcatIf(ByVal compareRange As Range, ByVal xCriteria As Variant, Optional ByVal stringsRange As Range, _
            Optional Delimiter As String, Optional NoDuplicates As Boolean) As String
' used as =exactly like COUNTIF() with two additional parameters of delimiter and "no duplicates" as TRUE/FALSE if
' concatenated values might duplicate  ex. =ConcatIf($A$1:$A$10,A1,", ",True)

Dim i As Long, j As Long  'code base by Mike Rickson MrExcel MVP

With compareRange.Parent
    Set compareRange = Application.Intersect(compareRange, Range(.UsedRange, .Range("a1")))
End With

If compareRange Is Nothing Then Exit Function
If stringsRange Is Nothing Then Set stringsRange = compareRange
Set stringsRange = compareRange.Offset(stringsRange.Row - compareRange.Row, _
                                    stringsRange.Column - compareRange.Column)
    
    For i = 1 To compareRange.Rows.Count
        For j = 1 To compareRange.Columns.Count
            If (Application.CountIf(compareRange.Cells(i, j), xCriteria) = 1) Then
                If InStr(ConcatIf, Delimiter & CStr(stringsRange.Cells(i, j))) <> 0 Imp Not (NoDuplicates) Then
                    ConcatIf = ConcatIf & Delimiter & CStr(stringsRange.Cells(i, j))
                End If
            End If
        Next j
    Next i
    ConcatIf = Mid(ConcatIf, Len(Delimiter) + 1)
End Function

Then use these non-array formulas instead. The benefit of this UDF is that it lays out just like a normal COUNTIF() formula, except it has the added delimiter parameter at the end.

Excel Workbook
ABCDEFGH
1Seq NumbPC5Product CodeColorSampleOptionsOptions Seq NumbOptions Colors
216361263612-0037red2063612-0037, 63612-0038, 63612-00411, 2, 3red, Blue, Green
326361263612-0038Blue0***
436361263612-0041Green0***
54U6002U6002-0012Yellow0***
65U6002U6002-0013Red0***
76U6002U6002-0016Black20U6002-0012, U6002-0013, U6002-0016, U6002-00174, 5, 6, 7Yellow, Red, Black, White
87U6002U6002-0017White0***
Sheet1
 
Upvote 0

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
The #NAME error means your sheet can't see the CONCATIF() function. The code should be placed into a regular code module, not a sheet module nor the ThisWorkbook module.

Press ALT-F11 to open the VBEditor
Click INSERT > MODULE and a window will appear
Paste in all of the code above
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

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