Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Object Type of a selection... counting rows in a selection


I have the following code:


Code
-------------------

Dim numPet As Integer
Dim sel ' what kind of object is this... so i can use count... "range", "application.selection" don't work

Worksheets("Datos").Activate
sel = Excel.Range("A4", Excel.Range("A4").End(xlDown)).Select

numPet = sel.Rows.Count

-------------------


and I need to count the number of rows selected. as there will be n
blank cells
counting like this should be fine. but i don't know what kind of objec
"sel" needs to be.

btw. any idea on how to apply a filter (select only cell containing
certain string) on the selection

--
Acid-Sk
-----------------------------------------------------------------------
Acid-Sky's Profile: http://www.excelforum.com/member.php...fo&userid=2650
View this thread: http://www.excelforum.com/showthread.php?threadid=39806

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Object Type of a selection... counting rows in a selection

Hi Acid-Sky

I am using code like

Dim iRows As Integer

Worksheets("Datos").Activate
iRows = Excel.Range("A4", Excel.Range("A4").End(xlDown)).Rows.Count

to count the number of rows.

If you would like to do something with this range try

Dim rPart As Range
Dim iRows As Integer

Worksheets("Datos").Activate
rPart = Excel.Range("A4", Excel.Range("A4").End(xlDown))
iRows = rPart.Rows.Count

I hoop this is the answer

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 74
Default Object Type of a selection... counting rows in a selection

Hi Acid-Sky


I am using code like


Dim iRows As Integer


Worksheets("Datos").Activate
iRows = Excel.Range("A4",
Excel.Range("A4").End(xlDown))*.Rows.Count


to count the number of rows.


If you would like to do something with this range try


Dim rPart As Range
Dim iRows As Integer


Worksheets("Datos").Activate
Set rPart = Excel.Range("A4", Excel.Range("A4").End(xlDown))
iRows = rPart.Rows.Count

a range is a complex item in Excel so you must use the Set commend.


I hoop this is the answer

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Object Type of a selection... counting rows in a selection


This code works

Code:
--------------------

Sub count()

Dim numPet As Integer
Dim sel As Range
' what kind of object is this... so i can use count... "range", "application.selection" don't work

Worksheets("Datos").Activate

Set sel = Excel.Range("A4", Excel.Range("A4").End(xlDown))

numPet = sel.Rows.count

End Sub

--------------------


--
instruite

I am B.E. Instrumentation and Control and write now working as Hardware
design engineer in automotive electrconics industry
------------------------------------------------------------------------
instruite's Profile: http://www.excelforum.com/member.php...o&userid=26539
View this thread: http://www.excelforum.com/showthread...hreadid=398066

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
dialog box selection type ORLANDO VAZQUEZ[_2_] Excel Discussion (Misc queries) 1 September 30th 09 08:24 PM
Object Selection W2 Excel Discussion (Misc queries) 2 August 26th 08 06:07 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
How to find what object type is returned from Selection property ? Krzysztof Klimczak[_3_] Excel Programming 1 October 2nd 03 11:33 PM


All times are GMT +1. The time now is 09:44 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"