Need to populate a cell with text value based on criteria

AndrewSDM

New Member
Joined
Apr 11, 2013
Messages
1
I've been having a great deal of trouble trying to figure out how to populate a cell with multiple text entries from certain criteria. I have information listed as such:

UMIDBox NumberFormat
1116mm
2116mm
318mm
4216mm
5235mm
623/4" Umatic
73VHS
81VHS
911/4" tape

<tbody>
</tbody>

I want to write a formula that will take this information from "Sheet 1" and populate cells in a "Sheet 2". I will need to populate cells with information such as "Number of items" per box and "Formats" in each box. I'm wanting formulas that will essentially help me get results like this:

Box NumberNumber of itemsMedia TypesUMIDs
1516mm, 8mm, VHS, 1/4"Tape1,2,3,8,9
2316mm, 35mm, 3/4"Umatic4,5,6
31VHS7

<tbody>
</tbody>


I know that I can accomplish this with =COUNTIF(Sheet1!BoxNumber,1) for instance for counting the number of items within a box. Is there a better formula I could be using?

What I'm most concerned about is, How can I populate the cells in my "Mediatypes" and "UMIDs" columns like in the examples I've listed?

Thanks for any help!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Sheet1, A:C, houses the data and Sheet2, A:D, the processing with A2 1, A3 2, and A3 3 the box numbers.

First, add
the following code as a module to your workbook usingAlt+F11...

Function aconcat(a As Variant, Optional sep As String = "") AsString
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function

and invoke on Sheet2...

B2, just enter and copy down:

=COUNTIF(Sheet1!$B$2:$B$10,A2)

C2, control+shift+enter, not just enter, and copy down:

=REPLACE(aconcat(IF(Sheet1!$B$2:$B$10=A2,", "&Sheet1!$C$2:$C$10,"")),1,2,"")

D2, control+shift+enter, not just enter, and copy down:

=REPLACE(aconcat(IF(Sheet1!$B$2:$B$10=A2,", "&Sheet1!$A$2:$A$10,"")),1,2,"")

 
Upvote 0
Hi Aladin

Thought I would try the Harlan Grove function as a learning exercise and believe that you woukd like to know that there is a problem in the function, first row, at the end, there is a space missing, it should read "As String" - so as it is, a copy and paste fails.

Hope that is helpful
 
Upvote 0
Hi Aladin

Thought I would try the Harlan Grove function as a learning exercise and believe that you woukd like to know that there is a problem in the function, first row, at the end, there is a space missing, it should read "As String" - so as it is, a copy and paste fails.

Hope that is helpful

I don't think there is anything wrong with it, unless my copy-and-paste action has failed. In case, the function directly from the workbook where I used it:

Function aconcat(a As Variant, Optional sep As String = "") As String
' Harlan Grove, Mar 2002
Dim y As Variant
If TypeOf a Is Range Then
For Each y In a.Cells
aconcat = aconcat & y.Value & sep
Next y
ElseIf IsArray(a) Then
For Each y In a
aconcat = aconcat & y & sep
Next y
Else
aconcat = aconcat & a & sep
End If
aconcat = Left(aconcat, Len(aconcat) - Len(sep))
End Function
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,245
Members
448,555
Latest member
RobertJones1986

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