Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 621
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Values to empty cell below filled cells in selection Harn88 Excel Programming 1 August 3rd 09 04:57 AM
Count Empty Cells in Range After Cells with Data David Excel Programming 16 September 17th 06 03:03 PM
count for empty cells tikchye_oldLearner57 Excel Discussion (Misc queries) 6 May 25th 06 08:41 PM
Message - Selection contains empty cells al007 Excel Programming 2 November 28th 05 11:07 AM
Selection of non-empty cells Adrian[_7_] Excel Programming 6 July 22nd 04 01:06 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"