VBA? to create unique records from list

MrFletch

New Member
Joined
Jul 18, 2017
Messages
4
Hello,
I would really appreciate some help.
I have a spreadsheet with 19 columns.
In column A there is a generic code
In Column K there is another generic code
In column D there is a quantity
A D K (qty)
ABC 1 123
XYZ 2 123
DEF 3 345
I would like to find a way to create a key in a new Column (where A is) with a primary key:
(Col A”-“Col K”-“one line per qty.)
All the other fields should be copied. For example:
A B E L
ABC-123-1 ABC 1 123
XYZ-123-1 XYZ 1 123
XYZ-123-2 XYZ 2 123
DEF-345-1 DEF 3 345
DEF-345-2 DEF 3 345
DEF-345-3 DEF 3 345

If you could help that would be great. Let me know if you require further information.
Regards,
Fletch
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
How about
Code:
Sub Concat3Col()

   Dim cnt As Long
   Dim Qty As Long
   
   Columns(1).Insert
   For cnt = Range("B" & Rows.Count).End(xlUp).Row To 2 Step -1
      Qty = Range("E" & cnt)
      If Qty > 1 Then
         Rows(cnt + 1).Resize(Qty - 1).Insert
         Rows(cnt).Resize(Qty).FillDown
         Range("E" & cnt).Value = 1
         Range("E" & cnt).AutoFill Range("E" & cnt).Resize(Qty), xlFillSeries
      End If
   Next cnt
   With Range("A2", Range("B" & Rows.Count).End(xlUp).Offset(, -1))
      .FormulaR1C1 = "=rc2 & ""-"" & rc12 & ""-"" & rc5"
      .Value = .Value
   End With
   
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,176
Members
453,021
Latest member
Justyna P

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