View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_8_] Rowan[_8_] is offline
external usenet poster
 
Posts: 55
Default select first empty cell in a range

This will loop through the cells in a the range going A5, B5, C5, D5,
A6, B6 etc until it finds an empty cell.

Sub lprng()
Dim cell As Range
For Each cell In Range("A5:D15")
If cell.Value = Empty Then
Debug.Print cell.Address
Exit For
End If
Next cell
End Sub

Or if you wanted to perform some operation on each cell in the range then:

Sub lprng()
Dim cell As Range
For Each cell In Range("A5:D15")
cell.Font.Bold = True
Next cell
End Sub

Hope this helps
Rowan

Shawn wrote:
Let's say I have a range of cells (A5:D15). I would like a VBA code that
would start at A5 and go down from A5 to A15, then start at B5 and progress
to B15, then C5 - C15 etc. until it finds the first empty cell.

Please help.