Click here to Skip to main content
15,741,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have made an application that populates a spreadsheet with several pieces of data. The data that is static (the data is always required in the same cell e.g. "A1") is fine and works a dream. However I need to work out how to make the program automatically check if the cell on in the next row is blank. Example:

I have a mall table in excel with months and some data:


Now next month I want the data to go in the April row and the following month May etc I have no idea how to do this my idea was to basically say look down the column when theres a blank fill it with the required data. will this work? If so how do I set about looking for empty cells, Im lost on this one!

Cheers the help.

Updated 11-Jul-11 2:39am

You can use the offset property to check the value of the next cell.

ActiveCell.offset(row, column).Value

you can then wrap some recursion round this to find the first empty row/column as required.
Share this answer
DanHodgson88 11-Jul-11 10:29am    
nice didn't know you could do that, found a solution to if you look below but yours is "nicer" than mine :)
Reiss 11-Jul-11 11:01am    
Glad you got it working, also kudos for working it out yourself ;-)
I believe I've found the way to find a blank cell, now got to put it in a loop to run through rows but for anyone whose interested. the code is:

int i = 0;

while(((excel.Range)xlWorkSheet.Cells[i,"Y"].Value2 != null)

xlWorkSHeet.get_Range("Y"+i,misValue).Value = landfill.Value;

May help someone else out :)
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