ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count no empty cells at the right of a selection (https://www.excelbanter.com/excel-programming/444750-count-no-empty-cells-right-selection.html)

avi

Count no empty cells at the right of a selection
 
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


Claus Busch

Count no empty cells at the right of a selection
 
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
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2

Gord Dibben[_2_]

Count no empty cells at the right of a selection
 
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

On Thu, 7 Jul 2011 09:58:50 -0700 (PDT), avi wrote:

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



All times are GMT +1. The time now is 03:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com