Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

New Post: Name of named range in formula changes when deleting rows

$
0
0
I have a template with named ranges for headings i.e =Head38 where Head38 references 'Sheet1':$A$2'. The headings are in row 3.
When I insert new rows using "InsertRowsBelow(n)", the headings remain the same. However when I delete rows (.Row(n).Delete()), the formula in the heading row changes to =Head28.

The heading is in row 3 and I am deleting blank rows from row 9 to row 100. See code below
xadj = 9
Do Until xadj = 100
   If String.IsNullOrEmpty(ws.Cell(xadj, 1).Value) Then
       ws.Row(xadj).Delete()
   Else
       If InStr(ws.Cell(xadj, 1).Value.ToString(), "Total capital") <> 0 Then
           Exit Do
       End If
       xadj = (xadj + 1)
   End If
Loop

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>