Search for string in excel file in two sheets and delete row
1 view (last 30 days)
Show older comments
Hello all!
As already in the title written i have an excel file with two sheets. Lets say excel file is called test.xls and there is sheet1 and sheet 2 in it. In every sheet there is in the row A for example A2: LOT ID and A3: BATID and also in sheet2 are these strings but at an different place like A4: LOT ID and A7: BATID
so what i want is a code that searches through both sheets looking for the MAPID and BATID and then delete the whole line.
i really dont know how to do this
this is what i tryied but it wont delete the line and also doesnt look in the second sheet:
%deleting specific lines in Excel
[~,~,rawData] = xlsread('padb2.xls');
name = 'LOT ID';
idx = find(strcmp(rawData(:,1),name),1);
if ~isempty(idx)
total = sum(cell2mat(rawData(idx,2:end)));
else
total = 0;
end
0 Comments
Answers (1)
KSSV
on 10 Sep 2018
[num,txt,raw] = xlsread('myfile.xlsx') ;
idx = contains(raw(:,1),'MAPID') ; % Assuming first column is the string present
raw(idx,:) = []
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!