Data Format Chage

zuh_143

New Member
Joined
Apr 17, 2014
Messages
1
Hello Guys!
My requirements are as under:-
[TABLE="width: 597"]
<tbody style="border: 0px; margin: 0px; padding: 0px; vertical-align: top; -webkit-font-smoothing: antialiased;">[TR]
[TD="colspan: 2"]Current Data Form[/TD]
[/TR]
[TR]
[TD]CustCode[/TD]
[TD]ItemCode[/TD]
[/TR]
[TR]
[TD]101[/TD]
[TD]400001[/TD]
[/TR]
[TR]
[TD]102[/TD]
[TD]400002[/TD]
[/TR]
[TR]
[TD]103[/TD]
[TD]400003[/TD]
[/TR]
[TR]
[TD]104[/TD]
[TD]400004[/TD]
[/TR]
[TR]
[TD]105[/TD]
[TD]400005[/TD]
[/TR]
</tbody>[/TABLE]
[TABLE="width: 597"]
<tbody style="border: 0px; margin: 0px; padding: 0px; vertical-align: top; -webkit-font-smoothing: antialiased;">[TR]
[TD="colspan: 2"]Required Data Form[/TD]
[/TR]
[TR]
[TD]CustCode[/TD]
[TD]ItemCode[/TD]
[/TR]
[TR]
[TD]101[/TD]
[TD]400001[/TD]
[/TR]
[TR]
[TD]101[/TD]
[TD]400002[/TD]
[/TR]
[TR]
[TD]101[/TD]
[TD]400003[/TD]
[/TR]
[TR]
[TD]101[/TD]
[TD]400004[/TD]
[/TR]
[TR]
[TD]101[/TD]
[TD]400005[/TD]
[/TR]
[TR]
[TD]102[/TD]
[TD]400001[/TD]
[/TR]
[TR]
[TD]102[/TD]
[TD]400002[/TD]
[/TR]
[TR]
[TD]102[/TD]
[TD]400003[/TD]
[/TR]
[TR]
[TD]102[/TD]
[TD]400004[/TD]
[/TR]
[TR]
[TD]102[/TD]
[TD]400005[/TD]
[/TR]
[TR]
[TD]103[/TD]
[TD]400001[/TD]
[/TR]
[TR]
[TD]103[/TD]
[TD]400002[/TD]
[/TR]
[TR]
[TD]103[/TD]
[TD]400003[/TD]
[/TR]
[TR]
[TD]103[/TD]
[TD]400004[/TD]
[/TR]
[TR]
[TD]103[/TD]
[TD]400005[/TD]
[/TR]
[TR]
[TD]104[/TD]
[TD]400001[/TD]
[/TR]
[TR]
[TD]104[/TD]
[TD]400002[/TD]
[/TR]
[TR]
[TD]104[/TD]
[TD]400003[/TD]
[/TR]
[TR]
[TD]104[/TD]
[TD]400004[/TD]
[/TR]
[TR]
[TD]104[/TD]
[TD]400005[/TD]
[/TR]
[TR]
[TD]105[/TD]
[TD]400001[/TD]
[/TR]
[TR]
[TD]105[/TD]
[TD]400002[/TD]
[/TR]
[TR]
[TD]105[/TD]
[TD]400003[/TD]
[/TR]
[TR]
[TD]105[/TD]
[TD]400004[/TD]
[/TR]
[TR]
[TD]105[/TD]
[TD]400005[/TD]
[/TR]
</tbody>[/TABLE]
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I am assuming Row 1 is headings (Cust Code, Item code)
Enter 101 in A2, and 400001 in B2.
In A3 enter the following formula and copy down:
=IF(COUNTIF($A$1:A2,A2)>4,A2+1,A2)
In B3 enter the following formula and copy down:
=IF(A3=A2,B2+1,400001)
 
Upvote 0
Are you wanting to overwrite your existing table of values with the expanded one? If so, give this macro a try...
Code:
Sub RedistributeCustCodesAndItemCodes()
  Dim X As Long, Index As Long, CustCodes As Variant
  CustCodes = Range("A2", Cells(Rows.Count, "A").End(xlUp))
  With Range("B2", Cells(Rows.Count, "B").End(xlUp))
    .Copy Range("B2:B" & .Rows.Count * UBound(CustCodes) + 1)
    For X = 2 To .Rows.Count * UBound(CustCodes) + 1
      If Cells(X, "B").Value = Range("B2").Value Then
        Index = Index + 1
        Cells(X, "A").Value = CustCodes(Index, 1)
      Else
        Cells(X, "A").Value = Cells(X - 1, "A").Value
      End If
    Next
  End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
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