How to delete Multiple rows in excel file using activex
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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;
0 commentaires
Réponses (1)
Bob Thompson
le 2 Fév 2018
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.
0 commentaires
Voir également
Catégories
En savoir plus sur ActiveX dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!