Way to delete certain pages from my Excel workbook based off a certain specification

Hello,

I currently have an excel file that is sorted via a v lookup which compares a part lists on a sheet to a separate master sheet in the same file, and if ALL the parts are not on the master sheet, the WHOLE part sheet should be deleted. I currently have a for each row within a for each sheet, that if my vlookup row is blank it should delete the sheet, but it is not deleting any sheet. Any recommendations?

@lmanier

What you can do is inside for each sheet…use a read range and read the data into datatable dt1

Also read the master file data into dt

Now use this in if condition dt1.AsEnumerable.All(function(x) dt.AsEnumerable.Any(function(y) y("PartColumnMastersheet").ToString.Equals(x("PartColumn").ToString)))

On then side all parts are present and on else side atleast one is missing…so save the sheetnames or directly use delete sheet

Cheers

Are we naming the master sheet dt
and the part sheet as ft1?

@lmanier

The data read from master sheet is read into dt datatble and from other sheets into dt1 datatable

These are the variable names and not sheetnames

Cheers

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.