How to create second excel sheet with only unique entries from first excel sheet


#1

Hi,

I have an excel sheet that I want to duplicate but only enter unique entries from the first sheet.
I am at a loss as to how to go about this. I’ve tried nested “for each row’s”, and looked at some of the more complicated answers for manipulating data tables, but that’s more advanced than I know how to understand.

Any help would be appreciated,
Thanks,


エクセルの重複を除いてデータを一つ一つ取り出す方法
#2

Can you give a little more information about what you mean by unique entries? It also helps to have example data with the same structure as yours.

Generally, you can get unique values in a datatable using dataTable.DefaultView.ToTable(true, “Column1”, “Column2”)

The first argument means you want distinct entries, the following (you can have one or more) specify columns that should be taken from the datatable. Note that this will only return the columns that you have specified. If you want to have more columns, you have to use GroupBy with an aggregate function.


#3

Probably the best approach is @alpaca solution. However, another approach for this is using linq which means a little bit of coding. yourDataTable.Rows.Cast(of DataRow).Distinct .This will work instantly if you only read the cells needed.