Click here to Skip to main content
15,916,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am Working on Excel Add in C# for Formatting.I want to loop in a column which consists of more than 10,000 rows. My requirement is if cells are not empty I have to do Some actions. In a column mostly 100 Cells are not empty. It is taking lot of time to loop in the whole column.

Is there any method that In a specified range it eliminates the blank cells and just iterates through the cells that are not empty.
this improves my performance 1000 times faster.

Any Help is appreciated. Thank you for your time
Posted
Comments
BillWoodruff 9-Dec-14 19:52pm    
I note that your solution will ignore Cells that have formulas; probably that doesn't matter ?

1 solution

I figured it out

Excel.Range HeaderStrtRange = activeWorksheet.UsedRange.Columns[HeaderStartCol, System.Type.Missing];
               //only get the range that cells are not empty
           Excel.Range NotBlankRange = HeaderStrtRange.SpecialCells(Excel.XlCellType.xlCellTypeConstants);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900