For i = 1 To 256
Now that Excel 2007 is out, you should use Columns.Count rather than hard
coding 256.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
"Gary''s Student" wrote in message
...
This UDF returns the column number of the first non-blank cell in row n
Function fnblank(n As Long) As Integer
fnblank = 0
For i = 1 To 256
If IsEmpty(Cells(n, i)) Then
Else
fnblank = i
Exit Function
End If
Next
End Function
This UDF returns the column number of the last non-blank cell in row n
Function lnblank(n As Long) As Integer
lnblank = 0
For i = 1 To 256
If IsEmpty(Cells(n, i)) Then
Else
lnblank = i
End If
Next
End Function
--
Gary's Student
"rob_bates" wrote:
Is there a formula that returns the first (or last) column that is
populated
in a row?
Row 6 has A6=blank, B6=1, C6=5, D6=4, E6=blank
If looking for the first number, I would like it to return Column B, for
the
last, Column D.
Thanks!
Rob.