Split text in cell and delete suplicates

avalite

New Member
Joined
Dec 17, 2019
Messages
6
Office Version
  1. 365
Platform
  1. Windows
Hello everyone,

I am working with an excel file which has more than 100 entries. Different items are separate by grade, such as A, AA, AAA or Prime (See attached). I want the grade removed from the item name and then delete all duplicate entries. Can someone helped me with it as I am new to VBA and my code is not really working. Thanks in advance.
 

Attachments

  • 2020-11-09 15_40_26-Product List-Nov 2020 - Excel.png
    2020-11-09 15_40_26-Product List-Nov 2020 - Excel.png
    5.8 KB · Views: 10

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
With your example:

DescriptionDescription
Bottom Flats ABottom Flats
Bottom Flats AA
Bottom Flats Prime
Bottom Flats AAA

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    TBD = Table.TransformColumns(Source, {{"Description", each Text.BeforeDelimiter(_, " ", 1), type text}}),
    Distinct = Table.Distinct(TBD)
in
    Distinct

btw. this is NOT vba
 
Upvote 0
Sorry, i am not sure how to run this query. Can you please help.

Thanks in advance
 
Upvote 0
  • your source should be a table (Excel Table)
  • use Ctrl+T
  • check the name of the table in the Name Manager (here it is Table1)
  • copy M code from the post
  • To view the Query Editor without loading or editing an existing workbook query, from the Data - New Query (or Get External Data section in the Power Query ribbon tab), select From Other Sources > Blank Query
  • or Data tab, then Get Data > From Other Sources > Blank Query
  • from the ribbon open Advanced Editor and replace all there with copied code
  • if the name of the table from Name Manager is different than in the code change the name in the code to proper name - both should be the same
  • then from the ribbon select Close&Load
 
Upvote 0
Maybe this then

VBA Code:
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 2 Step -1
    If InStr(Cells(r, 1), "Bottom Flats") And InStr(Cells(r - 1, 1), "Bottom Flats") Then
        Cells(r, 1).Value = "Bottom Flats"
        Rows(r - 1).Delete
End If
Next r
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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