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.
 
Right-click the cell and select format. The format should be General. If it is not then delete the formula, right-click again and select format, select General & click ok. Then paste the formula..
 
Upvote 0

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hello,

Please try it once more. Be sure to delete the initial formula. Once you have deleted the formula, change format to General and before entering the formula again save your workbook.

Once you have changed the format & saved the workbook, try entering the formula again. It should work now.
 
Upvote 0
If you could post a sample of your spreadsheet so that we see what is going on we might be able to help. Because I tried the formula on my workbook and it worked perfectly.
 
Upvote 0
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
 
Last edited:
Upvote 0
Hi,

UDF:

Code:
Function KCONCAT(Var As Variant, _
            Optional Delim As String = ",", _
            Optional Exc As Boolean = True) As String
            'Exc - Removing False from output
Dim v
If IsArray(Var) Then
    For Each v In Var
        KCONCAT = KCONCAT & Delim & v
    Next
    If Len(KCONCAT) > 1 Then
        If Exc Then
            KCONCAT = Trim$(Replace(Replace(Mid$(Trim$(KCONCAT), 2), _
            Delim & "False", ""), "False" & Delim, ""))
        Else
            KCONCAT = Mid$(Trim$(KCONCAT), 2)
        End If
    End If
Else: KCONCAT = Var
End If
End Function

use:

F2:

=IF($E2=20,KCONCAT(IF($B$2:$B$8=B2,$C$2:$C$8),", "),"")

and copied down.

Confirmed with CTRL + SHIFT + ENTER

HTH
 
Upvote 0
Hi jbeaucaire ..

the code given by u in the end Worked great...thanks a Ton ...all u guys...Saved me a lot of time...superb Stuff...

thanks once again..
 
Upvote 0
Hi Jbeaucaire,

I have been using the below mentioned Code and formula...But now when paste the formula i donot get the desired result but I get and output which says "#Name?" ...I now use excel 2007 ...Could u plz help.
First of all, this is the result I get from your sample data and criteria, which doesn't match your sample result...so check that.

Excel Workbook
ABCD
1PC5Product CodeSampleoptions
26361263612-00372063612-0037, 63612-0038, 63612-0041
36361263612-00380*
46361263612-00410*
5U6002U6002-00120*
6U6002U6002-00130*
7U6002U6002-001620U6002-0012, U6002-0013, U6002-0016, U6002-0017
8U6002U6002-00170*
Sheet1


The way I got this was to install a new function called JoinAll. This function will take a single criteria from one column and return a concatenated string of values from the second column. To add this function to your sheet:

Press ALT-F11 to open the VBEditor
Click INSERT > MODULE and a window will appear
Paste in all of this code:
Code:
Function JoinAll(ByVal BaseValue, ByRef rng As Range, ByVal delim As String)
Dim a, i As Long    'code base by Jindon MrExcel MVP
a = rng.Value
For i = 1 To UBound(a, 1)
    If a(i, 1) = BaseValue Then JoinAll = JoinAll & _
        IIf(JoinAll = "", "", delim) & a(i, 2)
Next
End Function
ALT-F11 to close the editor and save your sheet.

Now use the sample formula above shown how to identify the value to match, show the 2-column range, and then provide the delimiter...a comma in your formula.

Copy that formula down.
 
Upvote 0
Did you install the UDF into the workbook in Excel 2007? You'll have to save that workbook as a *.xlsm.
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,575
Members
449,089
Latest member
Motoracer88

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