Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I need to run a delete on a sheet based on criteria. Column B contains UPC's with approximately 1500 rows of Data
that look like what you see below. I want to delete every row EXCEPT the rows that have UPC's that END in 003 and then delete all empty rows.
Any help would be greatly appreciated!

Thank you!!

028200009524/000
028200009524/003
028200009524/003
028200009524/003
028200009531/000
028200009531/000

<tbody>
</tbody>
 
Last edited:
Re: Need help with a delete & sort macro

An alternative is to use Power Query/Get and Transform so long as you are running Excel 2010 or later. Here is the Mcode

Code:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Changed Type", "Column1", Splitter.SplitTextByDelimiter("/", QuoteStyle.Csv), {"Column1.1", "Column1.2"}),
    #"Filtered Rows" = Table.SelectRows(#"Split Column by Delimiter", each ([Column1.2] = "000")),
    #"Added Custom" = Table.AddColumn(#"Filtered Rows", "Custom", each [Column1.1]&"/"&[Column1.2]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column1.1", "Column1.2"})
in
    #"Removed Columns"

Translated, bring your table into PQ
Split the column of data using the "/' as your delimeter.
Filter out all unwanted rows
Concatenate the two columns adding back the delimeter.
Close and load to your workbook.
 
Last edited:
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,811
Messages
6,127,020
Members
449,351
Latest member
Sylvine

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