How to delete Multiple rows in excel file using activex
이전 댓글 표시
Activesheet.Rows.Item(1).Delete;
the above line will delete first row in the active excel sheet. I want to delete multiple rows so I used the following line, but it did not work :
Activesheet.Rows.Item([1,2,5,64]).Delete;
답변 (1개)
Bob Thompson
2018년 2월 2일
You could try running a for loop:
rowstodelete = [1 2 5 64];
for i = 1:length(rowstodelete);
Activesheet.Rows.Item(i).Delete;
end
I know it's not the most efficient, but for some reason I can't seem to get away from my love of loops.
Alternatively, instead of using Item, you might try using Range (Activesheet.Rows.Range().Delete). I don't know if that will work as it's been a while since I used the ActiveX commands, and it may only work for consecutive rows, but it could be better than running through a loop every time you want to delete stuff.
카테고리
도움말 센터 및 File Exchange에서 ActiveX에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!