![]() |
Inserting line numbers into the first column of an excel worksheet
I have an excel sheet that has the title row as the first row. The rows containing the data can start upto 5 rows below the title row leaving blank rows in between. I want to insert a column as the first column containing line numbers for the rows with the data. The line numbers have to start from the row where the data exists leaving the above blank rows. Is it possible to do this programmatically using C#. I tried using an identity column but it didn't work. The error says "Invalid Operation". Please help! Thanks in advance. -- rkappini ------------------------------------------------------------------------ rkappini's Profile: http://www.excelforum.com/member.php...o&userid=31216 View this thread: http://www.excelforum.com/showthread...hreadid=508883 |
Inserting line numbers into the first column of an excel worksheet
Hi
Into cell A5 enter the formula =IF(B5="","",ROW()-4) or =IF(AND(B5="",A6=""),"",ROW()-4) The first one leaves row number empty, when there is no entry on row, the second one numberes all rows until last non-empty one. Instead B5="" you can have some other entry existence check for row 5 - depending on your table setup. P.e. like this =IF(AND(COUNTA($B5:X5)=0,A6=""),"",ROW()-4) Copy the formula down for any reasonable amount of rows -- Arvi Laanemets ( My real mail address: arvi.laanemets<attarkon.ee ) "rkappini" wrote in message ... I have an excel sheet that has the title row as the first row. The rows containing the data can start upto 5 rows below the title row leaving blank rows in between. I want to insert a column as the first column containing line numbers for the rows with the data. The line numbers have to start from the row where the data exists leaving the above blank rows. Is it possible to do this programmatically using C#. I tried using an identity column but it didn't work. The error says "Invalid Operation". Please help! Thanks in advance. -- rkappini ------------------------------------------------------------------------ rkappini's Profile: http://www.excelforum.com/member.php...o&userid=31216 View this thread: http://www.excelforum.com/showthread...hreadid=508883 |
All times are GMT +1. The time now is 10:38 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com