Count no empty cells at the right of a selection

  • Thread starter Thread starter avi
  • Start date Start date
A

avi

Hello,

I am looking for a robust code that will count no empty cells at the
right of a selection

Using Range(Selection, Selection.End(xlToRight)).Select seems to
capture all the cells only the next block and not all the columns at
the right

Thanks
Avi
 
Hello Avi,

Am Thu, 7 Jul 2011 09:58:50 -0700 (PDT) schrieb avi:
Using Range(Selection, Selection.End(xlToRight)).Select seems to
capture all the cells only the next block and not all the columns at
the right

try:
myCount = Selection.Cells.Count - _
WorksheetFunction.CountBlank(Selection.Offset(0, 1))


Regards
Claus Busch
 
Sub select_to_lastcolumn()
'select to last filled column in activerow, ignoring intermediate blanks
Range(ActiveCell, Cells(ActiveCell.Row, Columns.Count).End(xlToLeft)).Select
End Sub

What the code does is start from far right column then work back until it
reaches the first non-blank cell.


Gord Dibben MS Excel MVP
 
Back
Top