prefix = "A-"; class Deleter { constructor() { this.from = 0; this.to = 0; } mark(y) { if (this.from == 0) { this.from = y; } this.to = y; } execute() { if (this.from == 0) { return 0; } count = this.to - this.from + 1; DeleteRow(this.from, this.to); this.from = 0; this.to = 0; return count; } } function find(to) { for (y = 1; y < to; y++) { if ([9,y] == [9,to]) { return y; } } return 0; } deleter = new Deleter(); for (y = 1; y <= Bottom; y++) { if (left([9,y], len(prefix)) != prefix) { deleter.mark(y); continue; } found = find(y); if (found > 0) { [16,found] += [16,y]; deleter.mark(y); continue; } y -= deleter.execute(); } deleter.execute();