A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
Hi,
No need to loop...
The first empty cell in column C is given by:
Set r = Range("C1").End(xlDown).Offset(1)
but you need to take care in the case that C2:Clastrow are not populated then r will end up as the bottom row of the sheet! Safest test is:
'if col C has a header row use: If Range("C2").Value = "" Then
Set r = Range("C2")
Else
Set r = Range("C1").End(xlDown).Offset(1)
End If
'if col C does not have a header row use: If Range("C1").Value = "" Then
Set r = Range("C1")
ElseIf Range("C2").Value = "" Then
Set r = Range("C2")
Else
Set r = Range("C1").End(xlDown).Offset(1)
End If
Alternatively, you can use special cells (I believe these are reliable in Excel 2010):
Set r = Columns("C:C").SpecialCells(xlCellTypeBlanks).Cells(1)
but that will only return truely blank cells, i.e. not any cell containing a formula that has returned "".
Cheers
Rich