Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default How to count optionbuttons on specific range on worksheet

HI,

I know the method to count the option buttons(From form toolbar) on one
worksheet as follow:

Worksheets("Sheet 1").OptionButtons.Count

Now, I want to count option buttons on specific range on worksheet,
like range"D10:F15"

I used the following code:

Worksheets("Sheet 1").range("D10:F15").OptionButtons.Count

However, it doesn't work.

Do you have some ideas about this issue? which clause should I use?
Thank you inadvance!!!


Best Regards

Sam

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to count optionbuttons on specific range on worksheet

Hi Sam,

Try:

'=============
Public Sub Tester()
Dim rng As Range
Dim OP As OptionButton
Dim iCtr As Long

Set rng = Range("D1:F15")
For Each OP In ActiveSheet.OptionButtons
If Not Intersect(OP.TopLeftCell, rng) Is Nothing Then
iCtr = iCtr + 1
End If
Next OP

MsgBox iCtr

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


--
---
Regards,
Norman



"sam" wrote in message
oups.com...
HI,

I know the method to count the option buttons(From form toolbar) on one
worksheet as follow:

Worksheets("Sheet 1").OptionButtons.Count

Now, I want to count option buttons on specific range on worksheet,
like range"D10:F15"

I used the following code:

Worksheets("Sheet 1").range("D10:F15").OptionButtons.Count

However, it doesn't work.

Do you have some ideas about this issue? which clause should I use?
Thank you inadvance!!!


Best Regards

Sam



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default How to count optionbuttons on specific range on worksheet

A suggested enhancement to Norman's idea

Dim rng1 as Range

For Each OP In ActiveSheet.OptionButtons
set rng1 = Range(OP.TopLeftCell,OP.BottomRightCell)
If Not Intersect(rng1, rng) Is Nothing Then

Depends on what you consider to be within that range.

--
Regards,
Tom Ogilvy




"Norman Jones" wrote:

Hi Sam,

Try:

'=============
Public Sub Tester()
Dim rng As Range
Dim OP As OptionButton
Dim iCtr As Long

Set rng = Range("D1:F15")
For Each OP In ActiveSheet.OptionButtons
If Not Intersect(OP.TopLeftCell, rng) Is Nothing Then
iCtr = iCtr + 1
End If
Next OP

MsgBox iCtr

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


--
---
Regards,
Norman



"sam" wrote in message
oups.com...
HI,

I know the method to count the option buttons(From form toolbar) on one
worksheet as follow:

Worksheets("Sheet 1").OptionButtons.Count

Now, I want to count option buttons on specific range on worksheet,
like range"D10:F15"

I used the following code:

Worksheets("Sheet 1").range("D10:F15").OptionButtons.Count

However, it doesn't work.

Do you have some ideas about this issue? which clause should I use?
Thank you inadvance!!!


Best Regards

Sam




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default How to count optionbuttons on specific range on worksheet

Hi Tom,

A suggested enhancement to Norman's idea


set rng1 = Range(OP.TopLeftCell,OP.BottomRightCell)


Depends on what you consider to be within that range.


A distinct enhancement - and I like it!


---
Regards,
Norman


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 BETWEEN A SPECIFIC DATE RANGE Dave Excel Discussion (Misc queries) 4 June 3rd 10 11:26 AM
Count Specific word in Specific range [email protected] Excel Programming 1 May 16th 06 10:55 AM
Count Specific word in specific range [email protected] Excel Worksheet Functions 2 May 16th 06 10:30 AM
Count If Specific word in specific range [email protected] Excel Discussion (Misc queries) 2 May 16th 06 10:14 AM
Count used cells, in a specific range... Steff_DK[_4_] Excel Programming 3 April 21st 04 12:43 PM


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