View Single Post
  #11   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Count latest number of continous not-empty cells in a row.

Hi again,

Am Wed, 14 Jan 2015 18:33:40 +0100 schrieb Claus Busch:

Function myCnt(myRng As Range) As Long


if there could be values right of your range you better try:

Function myCnt(myRng As Range) As Long
'Only for ranges A:Z
Dim varTmp As Variant, varRng As Variant
Dim i As Long, LCol As Long

varRng = Split(myRng.Address(0, 0), ":")
LCol = Asc(Left(varRng(1), 1)) - 64

varTmp = myRng
For i = LCol To 1 Step -1
If Len(varTmp(1, i)) = 0 Then
myCnt = LCol - i
Exit Function
ElseIf i = 1 Then
myCnt = myRng.Cells.Count
End If
Next
End Function


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional