Reputation: 33
I'm trying to remove the first row of a given range. But getting a Type Mismatch error.
From this examples: Excel with c#: Exculde first rows when copying a range
I'm trying something like this:
Excel.Range rngNoHeaders = NamedRange.RefersToRange[NamedRange.RefersToRange.Cells[2, 1], NamedRange.RefersToRange.SpecialCells(Excel.XlCellType.xlCellTypeLastCell)];
Any help is appreciated. Thanks in advance!
Upvotes: 2
Views: 1212
Reputation: 16397
Given any range (the example below I just picked one arbitrarily), this is how you would delete the first row of that range:
Excel.Range r = ws.Range["A18:A23"];
r.Rows[1].EntireRow.Delete();
So I assumed NamedRange
is a object of type Range? If so:
NamedRange.Rows[1].EntireRow.Delete();
Upvotes: 1