Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Count number of rows with actually selecting

I'm using "Selection.Count" to count the number of cells in a range. How
would I do this without actually visibly selecting the range i.e. I don't
want the active cell to change from that selected by the user when they
started my procedure.

thanks

...pc


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Count number of rows with actually selecting

That would depend. Do you want the UsedRange

ACtivesheet.UsedRange.Cells.Count

from the activecell to the end of the currentregion

activecell.currentregion.Cells.Count

or something else?

--
HTH

Bob Phillips

"PC" <paulm dot c @ iol dot ie wrote in message
...
I'm using "Selection.Count" to count the number of cells in a range. How
would I do this without actually visibly selecting the range i.e. I don't
want the active cell to change from that selected by the user when they
started my procedure.

thanks

..pc




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Count number of rows with actually selecting

One way:

numCells = rng.Count


where rng is the range of interest.

You almost never need to select anything - working with range objects
directly makes your code smaller, faster, and IMO easier to maintain.


In article ,
"PC" <paulm dot c @ iol dot ie wrote:

I'm using "Selection.Count" to count the number of cells in a range. How
would I do this without actually visibly selecting the range i.e. I don't
want the active cell to change from that selected by the user when they
started my procedure.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default Count number of rows with actually selecting

Count is the property of a range. so something like this will work

Dim rng As Range
Dim wks As Worksheet

Set wks = ActiveSheet
Set rng = wks.Range("B2:B100")

MsgBox rng.Count

HTH

Jim Thomlinson


"PC" wrote:

I'm using "Selection.Count" to count the number of cells in a range. How
would I do this without actually visibly selecting the range i.e. I don't
want the active cell to change from that selected by the user when they
started my procedure.

thanks

...pc



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Count number of rows with actually selecting

And if the range is a collection of rows instead of cells, something
like the following will work to count the rows:

Dim rng As Range
Dim wks As Worksheet

Set wks = ActiveSheet
Set rng = wks.Range("B2:C100").Rows

MsgBox rng.Count

Alan Beban

Jim Thomlinson wrote:
Count is the property of a range. so something like this will work

Dim rng As Range
Dim wks As Worksheet

Set wks = ActiveSheet
Set rng = wks.Range("B2:B100")

MsgBox rng.Count

HTH

Jim Thomlinson


"PC" wrote:


I'm using "Selection.Count" to count the number of cells in a range. How
would I do this without actually visibly selecting the range i.e. I don't
want the active cell to change from that selected by the user when they
started my procedure.

thanks

...pc





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Count number of rows with actually selecting

Thanks for your input - I worked out a solution to the problem from the
suggestions given


"PC" <paulm dot c @ iol dot ie wrote in message
...
I'm using "Selection.Count" to count the number of cells in a range. How
would I do this without actually visibly selecting the range i.e. I don't
want the active cell to change from that selected by the user when they
started my procedure.

thanks

..pc




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
COUNT NUMBER OF ROWS Keep It Simple Stupid Excel Worksheet Functions 2 February 9th 07 06:54 PM
Count number of rows, where non relevant rows are hidden Pieter Excel Discussion (Misc queries) 2 November 8th 06 12:24 PM
Count rows and insert number to count them. Mex Excel Discussion (Misc queries) 6 August 23rd 06 02:29 AM
Selecting a large number of rows, but not all Katherine New Users to Excel 4 January 27th 05 11:54 PM
Auto selecting the number of rows! aiyer[_33_] Excel Programming 1 August 6th 04 10:58 PM


All times are GMT +1. The time now is 10:44 PM.

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

About Us

"It's about Microsoft Excel"