Excel - How to distribute data in Excel using Excel functions

Dasarath

New Member
Joined
Jul 9, 2017
Messages
5
Hello All,
I am trying to create a excel formula(index and ceiling functions)for below mention data.Everyday I have to do it manually please can anybody me to sort this problem.

Thanks in Advance


Here is the Data table,Each code should got to single name.Codes and Names are dynamic

CodeCOUNTIFNamesNames
SOO122XX
SOO122YX
SOO22ZY
SOO22 Y
SOW63 Z
SOW63 Z
SOW63 Z
SOW74 X
SOW74 X
SOW74 X
SOW74 X

<colgroup><col><col><col span="2"></colgroup><tbody>
</tbody>
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
Welcome to the forums Dasarath

If this is the current data set that you have, what would be the desired output you are looking for ? Please give an example
 
Upvote 0
Hi,
I will get a rawdata like below table.

CodeNames
SOO12X
SOO12Y
SOO2Z
SOO2
SOW6
SOW6
SOW6
SOW7
SOW7
SOW7
SOW7
SOX11
SOX11
YOX4
YOX4
YOX4
YOX4
YOX4
YOX4
YOX4
YOX1

<colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>

Once i get this data i apply Countif function to get the each Code Count. Then i will sort the data with Code Column.

Here starts my real work ,In ColumnC We have to apply formula ,where in ColumnA Code:SOO12 is repeated 2 times this will assign to Name:X 2times ,Code:SOO2 will assign to2times to Name:Y and Code:SOW6 is repeated 3times & will assign to Z 3times .Now 3 Names are completed ,next code will take X and so on..and output should look like ColumnE ,This is how i do manually everyday .Everyday Rawdata will be around 5000Codes repeated.

Finally output should be like below table:

CodeCOUNTIFOutput
SOO122X
SOO122X
SOO22Y
SOO22Y
SOW63Z
SOW63Z
SOW63Z
SOW74X
SOW74X
SOW74X
SOW74X
SOX112Y
SOX112Y
YOX47Z
YOX47Z
YOX47Z
YOX47Z
YOX47Z
YOX47Z
YOX47Z
YOX51X

<colgroup><col span="2"><col></colgroup><tbody>
</tbody>


Please help me out with the formula,thank you.
 
Upvote 0
Sorry Dasarath I got so busy at work I couldn't get back to you earlier. You can use the below VBA code assuming you have your "Codes" in column A and your "Names" in column B & your header is in row # 1 & your data starts in row # 2 ... Enjoy


Code:
Sub test()

Dim strCode As String, strName As String

Dim CodesLastRow As Single, NamesLastRow As Single
CodesLastRow = ActiveSheet.Range("A" & Rows.Count).End(xlUp).Row
NamesLastRow = ActiveSheet.Range("B" & Rows.Count).End(xlUp).Row

Dim x As Single, y As Single

strCode = ActiveSheet.Range("A2").Value
y = 2

For x = 2 To CodesLastRow
    If ActiveSheet.Range("A" & x).Value = strCode Then
        ActiveSheet.Range("C" & x).Value = ActiveSheet.Range("B" & y).Value
    Else
        If y + 1 <= NamesLastRow Then
            y = y + 1
            strCode = ActiveSheet.Range("A" & x).Value
            ActiveSheet.Range("C" & x).Value = ActiveSheet.Range("B" & y).Value
        Else
            y = 2
            strCode = ActiveSheet.Range("A" & x).Value
            ActiveSheet.Range("C" & x).Value = ActiveSheet.Range("B" & y).Value
        End If
    End If
Next x
    
MsgBox "Task completed for all " & CodesLastRow & " records :)", vbInformation

End Sub
 
Last edited:
Upvote 0
Thank you so much for your time this is what i am looking for working like a charm ,Once again million thanks .
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
Latest member
dbomb1414

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