Here is the macro vba that inserts a new column on the side and extract the first "expected cost" of each "model" and delete the rest of the rows
Below is the macro vba that I created.
Sub FirstValue()
Dim LastRow As Long
Dim i As Long
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
Range("A1").Offset(0, 1).EntireColumn.Insert
Range("A1").Value = "Model"
Range("A1").Offset(0, 1).Value = "Expected Cost"
''''' TextToColumns to separate expected cost from model
Range("A2:A" & LastRow).Select
Application.CutCopyMode = False
Selection.TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, _
Semicolon:=False, Comma:=False, Space:=True, Other:=False, FieldInfo _
:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
''''' Delete all but the first of each model
For i = LastRow To 2 Step -1
If Cells(i, 1) = Cells(i - 1, 1) Then Cells(i, 1).EntireRow.Delete
Next i
End Sub
How do I make this code to fit my dataset below?
Model(Editable) Amount Per Unit(Editable) Expected QTY(Editable) Expected Cost(Editable)
WM3370HWA.ABWEPUS 107. 0. 4.00
WM3370HWA.ABWEPUS 107. 3. 321.00
WM3370HWA.ABWEPUS 107. 0. 38.00
WM4270HWA.ABWEPUS 142. 12. 1693.00
WM4270HWA.ABWEPUS 142. 90. 12721.00
WM8000HWA.ABWEEUS 232. 5. 1147.00
WM8000HWA.ABWEEUS 232. 37. 8584.00
WM8000HWA.ABWEEUS 232. 0. 29.00
WT5680HVA.ASSEPUS 151. 12. 1800.00
WT5680HVA.ASSEPUS 151. 90. 13519.00
DLEX4270W.ABWEEUS 142. 7. 987.00
DLEX4270W.ABWEEUS 142. 52. 7384.00
DLEX4270W.ABWEEUS 142. 0. 33.00
WT1801HVA.ASSEEUS 102. 5. 483.00
WT1801HVA.ASSEEUS 102. 36. 3626.00
DLEY1701V.ASSEEUS 113. 3. 311.00
DLEY1701V.ASSEEUS 113. 21. 2337.00
Bookmarks