Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default counts rows in data

Forgot how to write the code for counting rows in a selection. I need to set
up a for next loop to work in the data range, but the number of rows in the
data range changes periodically.


--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default counts rows in data

Hi Bryan

Dim i as long

For i = 1 to Selection.Rows.Count

'Your code

Next i


---
Regards,
Norman



"Bryan Brassell" wrote in message
...
Forgot how to write the code for counting rows in a selection. I need to
set
up a for next loop to work in the data range, but the number of rows in
the
data range changes periodically.


--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default counts rows in data

Thanks - only thing left, is how do I make the selection each time? Start in
cell a1 and use somthing like activerange, etc?
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141


"Norman Jones" wrote:

Hi Bryan

Dim i as long

For i = 1 to Selection.Rows.Count

'Your code

Next i


---
Regards,
Norman



"Bryan Brassell" wrote in message
...
Forgot how to write the code for counting rows in a selection. I need to
set
up a for next loop to work in the data range, but the number of rows in
the
data range changes periodically.


--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default counts rows in data

Hi Bryan,

Thanks - only thing left, is how do I make the selection each time?


Ideally, you do not! It is rarely necessary, and is usually inefficient, to
make selections. A preferable approach would be to set the range to an
object variable and manipulate the variable.

For example:

'===============
Sub TestIt()
Dim rng As Range
Dim rCell As Range

Set rng = Selection

For Each rCell In rng.Cells
If rCell.Value 100 Then
'do something, e.g.;
rCell.Interior.ColorIndex = 6
Else
'Do something else, e.g.:
rCell.Value = rCell.Value * 2
End If
Next rCell

End Sub
'<<===============

---
Regards,
Norman



"Bryan Brassell" wrote in message
...
Thanks - only thing left, is how do I make the selection each time? Start
in
cell a1 and use somthing like activerange, etc?
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141


"Norman Jones" wrote:

Hi Bryan

Dim i as long

For i = 1 to Selection.Rows.Count

'Your code

Next i


---
Regards,
Norman



"Bryan Brassell" wrote in
message
...
Forgot how to write the code for counting rows in a selection. I need
to
set
up a for next loop to work in the data range, but the number of rows in
the
data range changes periodically.


--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default counts rows in data

or could you loop through the range?

Range("test").Address

--


Gary


"Bryan Brassell" wrote in message
...
Thanks - only thing left, is how do I make the selection each time? Start
in
cell a1 and use somthing like activerange, etc?
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141


"Norman Jones" wrote:

Hi Bryan

Dim i as long

For i = 1 to Selection.Rows.Count

'Your code

Next i


---
Regards,
Norman



"Bryan Brassell" wrote in
message
...
Forgot how to write the code for counting rows in a selection. I need
to
set
up a for next loop to work in the data range, but the number of rows in
the
data range changes periodically.


--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default counts rows in data

Either

For i = 1 to ACtivesheet.UsedRange.Rows.Count

or

For i = 1 To Cells(Rows.Count,"A").End(xlUp).Row

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Bryan Brassell" wrote in message
...
Thanks - only thing left, is how do I make the selection each time? Start

in
cell a1 and use somthing like activerange, etc?
--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141


"Norman Jones" wrote:

Hi Bryan

Dim i as long

For i = 1 to Selection.Rows.Count

'Your code

Next i


---
Regards,
Norman



"Bryan Brassell" wrote in

message
...
Forgot how to write the code for counting rows in a selection. I need

to
set
up a for next loop to work in the data range, but the number of rows

in
the
data range changes periodically.


--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default counts rows in data

Bryan

Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column).End(xlUp)).Select

OR No selection.......

Set Rng = Range(ActiveCell, Cells(Rows.Count, ActiveCell.Column).End(xlUp))

With Rng
'do what you want
End With


Gord Dibben Excel MVP

On Fri, 2 Dec 2005 12:43:03 -0800, "Bryan Brassell"
wrote:

Thanks - only thing left, is how do I make the selection each time? Start in
cell a1 and use somthing like activerange, etc?

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default counts rows in data

I like Bob Phillips' second offering because it is easy to modify which
column you want the row count from.

Mike F
"Bryan Brassell" wrote in message
...
Forgot how to write the code for counting rows in a selection. I need to
set
up a for next loop to work in the data range, but the number of rows in
the
data range changes periodically.


--
Regards,

Bryan Brassell
Padgett Business Services
281-897-9141



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
average daily counts to weekly counts Dave Excel Discussion (Misc queries) 0 June 17th 08 06:24 PM
eliminate data entry of counts by state redhead New Users to Excel 3 February 2nd 08 04:02 AM
Pivot Table counts instead of data BobS9895 Excel Worksheet Functions 4 May 5th 06 09:35 PM
Would like to add 0 counts to worksheet after data is returned fro Erikka T Excel Programming 1 July 30th 04 03:25 AM
Would like to add 0 counts to worksheet after data is returned fro Dave Peterson[_3_] Excel Programming 0 July 29th 04 02:34 AM


All times are GMT +1. The time now is 11:48 PM.

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"