Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default Checking Options in UserForms Collection

Hi;

The user form, frmOptSelect, has a number of frames, each with a number of
option controls. The algoritms for all combinations of options are not
currently available, so I'm disabling certain options for now.
I'm trying to make sure that an option is selected in each frame on the form
before I click the btnOpen button. In:

Private Sub btnOpen_Click () event procedure and right at the top, I
inserted:
........ CheckOptions
which is a regular macro:

Sub CheckOptions()
Dim myOption As Control
Dim myFlag As Integer
.................................................. ....
' check options in frame grpSeries
For Each myOption In UserForms(1).grpSeries.Controls
......If myOption.Value = True Then myFlag = 1
Next myOption
If myFlage < 1 Then MsgBox "Select B- or GEL-Series"
.................................................. .....
' repeat for all frames
.................................................. .....

I got " Run-time error '9': Subscript out of range", and the above For Each
statement is higlighted!

Any suggestions ? Thank you
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Checking Options in UserForms Collection

probably zero basedinstead of
UserForms(1).
try
me.




"monir" wrote:

Hi;

The user form, frmOptSelect, has a number of frames, each with a number of
option controls. The algoritms for all combinations of options are not
currently available, so I'm disabling certain options for now.
I'm trying to make sure that an option is selected in each frame on the form
before I click the btnOpen button. In:

Private Sub btnOpen_Click () event procedure and right at the top, I
inserted:
....... CheckOptions
which is a regular macro:

Sub CheckOptions()
Dim myOption As Control
Dim myFlag As Integer
.................................................. ...
' check options in frame grpSeries
For Each myOption In UserForms(1).grpSeries.Controls
.....If myOption.Value = True Then myFlag = 1
Next myOption
If myFlage < 1 Then MsgBox "Select B- or GEL-Series"
.................................................. ....
' repeat for all frames
.................................................. ....

I got " Run-time error '9': Subscript out of range", and the above For Each
statement is higlighted!

Any suggestions ? Thank you

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default Checking Options in UserForms Collection

Patrick;

Replacing UserForms(1). by Me. produced:
........."Compile error: Invalid use of Me keyword"

Another suggestion? Thank you.



"Patrick Molloy" wrote:

probably zero basedinstead of
UserForms(1).
try
me.




"monir" wrote:

Hi;

The user form, frmOptSelect, has a number of frames, each with a number of
option controls. The algoritms for all combinations of options are not
currently available, so I'm disabling certain options for now.
I'm trying to make sure that an option is selected in each frame on the form
before I click the btnOpen button. In:

Private Sub btnOpen_Click () event procedure and right at the top, I
inserted:
....... CheckOptions
which is a regular macro:

Sub CheckOptions()
Dim myOption As Control
Dim myFlag As Integer
.................................................. ...
' check options in frame grpSeries
For Each myOption In UserForms(1).grpSeries.Controls
.....If myOption.Value = True Then myFlag = 1
Next myOption
If myFlage < 1 Then MsgBox "Select B- or GEL-Series"
.................................................. ....
' repeat for all frames
.................................................. ....

I got " Run-time error '9': Subscript out of range", and the above For Each
statement is higlighted!

Any suggestions ? Thank you

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default Checking Options in UserForms Collection

In the For Each statement:
' check options in frame grpSeries
.......For Each myOption In UserForms(1).grpSeries.Controls

if I replace UserForms(1) by UserForm("frmOptSelect")
now it is "Run-time error '13': Type mismatch", and the For Each statement
is highlighted. (That is different from the earlier: "Run-time error '9':
Subscript out of range" when I used the user form index.)

Does this reveal anything?

Since I'm referring to the user form object in a standard macro, shouldn't
the reference to the user form be specific either by index or by name ?

Thanks again.


"monir" wrote:

Patrick;

Replacing UserForms(1). by Me. produced:
........"Compile error: Invalid use of Me keyword"

Another suggestion? Thank you.



"Patrick Molloy" wrote:

probably zero basedinstead of
UserForms(1).
try
me.




"monir" wrote:

Hi;

The user form, frmOptSelect, has a number of frames, each with a number of
option controls. The algoritms for all combinations of options are not
currently available, so I'm disabling certain options for now.
I'm trying to make sure that an option is selected in each frame on the form
before I click the btnOpen button. In:

Private Sub btnOpen_Click () event procedure and right at the top, I
inserted:
....... CheckOptions
which is a regular macro:

Sub CheckOptions()
Dim myOption As Control
Dim myFlag As Integer
.................................................. ...
' check options in frame grpSeries
For Each myOption In UserForms(1).grpSeries.Controls
.....If myOption.Value = True Then myFlag = 1
Next myOption
If myFlage < 1 Then MsgBox "Select B- or GEL-Series"
.................................................. ....
' repeat for all frames
.................................................. ....

I got " Run-time error '9': Subscript out of range", and the above For Each
statement is higlighted!

Any suggestions ? Thank you

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default Checking Options in UserForms Collection

I didn't realise that the code was in a module. I assumed that you'd used
the form's own code sheet. Why don't you?

"monir" wrote in message
...
In the For Each statement:
' check options in frame grpSeries
......For Each myOption In UserForms(1).grpSeries.Controls

if I replace UserForms(1) by UserForm("frmOptSelect")
now it is "Run-time error '13': Type mismatch", and the For Each statement
is highlighted. (That is different from the earlier: "Run-time error '9':
Subscript out of range" when I used the user form index.)

Does this reveal anything?

Since I'm referring to the user form object in a standard macro, shouldn't
the reference to the user form be specific either by index or by name ?

Thanks again.


"monir" wrote:

Patrick;

Replacing UserForms(1). by Me. produced:
........"Compile error: Invalid use of Me keyword"

Another suggestion? Thank you.



"Patrick Molloy" wrote:

probably zero basedinstead of
UserForms(1).
try
me.




"monir" wrote:

Hi;

The user form, frmOptSelect, has a number of frames, each with a
number of
option controls. The algoritms for all combinations of options are
not
currently available, so I'm disabling certain options for now.
I'm trying to make sure that an option is selected in each frame on
the form
before I click the btnOpen button. In:

Private Sub btnOpen_Click () event procedure and right at the top,
I
inserted:
....... CheckOptions
which is a regular macro:

Sub CheckOptions()
Dim myOption As Control
Dim myFlag As Integer
.................................................. ...
' check options in frame grpSeries
For Each myOption In UserForms(1).grpSeries.Controls
.....If myOption.Value = True Then myFlag = 1
Next myOption
If myFlage < 1 Then MsgBox "Select B- or GEL-Series"
.................................................. ....
' repeat for all frames
.................................................. ....

I got " Run-time error '9': Subscript out of range", and the above
For Each
statement is higlighted!

Any suggestions ? Thank you





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 215
Default Checking Options in UserForms Collection

Partick;

There are 2 reasons (I thought) for having a separate macro code for the task:
1. it makes the form's code neater, specially if other frames are added
later to the form and their options need to be similarly cheked; and
2. in the case of multiple user forms, only the standard module's code
needs to be expanded

Now, if you meant to place the regular macro in the form's code sheet, not
just the macro's code, then here it is. I moved the macro Sub CheckOptions
() to the form's code sheet, and replaced UserForms(1) reference by Me (and
later by nothing).
Clicking the btnOpen button, which has the call to the CheckOptions macro
(as illustrated below), does not produce run-time errors, and does not
display the MsgBox message!! Stepping into the macro suggests that the
message should be displayed !
Maybe I should follow the MsgBox statement by SetFocous on the relevant
option! or maybe not ! Is it the regular macro in the Class-Module Forms
code sheet that is causing all these troubles ?

Here is the latest attempt, with all macros in the form's code sheet:
frmOptSelect

Private Sub btnOpen_Click ()
................................................
CheckOptions
...............................................
End Sub

Sub CheckOptions()
Dim myOption As Control
Dim myFlag As Integer
.................................................. ....
' check options in frame grpSeries
For Each myOption In Me.grpSeries.Controls
......If myOption.Value = True Then myFlag = 1
Next myOption
If myFlage < 1 Then MsgBox "Select B- or GEL-Series"
.................................................. .....
' repeat for all frames
.................................................. .....

Other suggestions? Thank you.



"Patrick Molloy" wrote:

I didn't realise that the code was in a module. I assumed that you'd used
the form's own code sheet. Why don't you?

"monir" wrote in message
...
In the For Each statement:
' check options in frame grpSeries
......For Each myOption In UserForms(1).grpSeries.Controls

if I replace UserForms(1) by UserForm("frmOptSelect")
now it is "Run-time error '13': Type mismatch", and the For Each statement
is highlighted. (That is different from the earlier: "Run-time error '9':
Subscript out of range" when I used the user form index.)

Does this reveal anything?

Since I'm referring to the user form object in a standard macro, shouldn't
the reference to the user form be specific either by index or by name ?

Thanks again.


"monir" wrote:

Patrick;

Replacing UserForms(1). by Me. produced:
........"Compile error: Invalid use of Me keyword"

Another suggestion? Thank you.



"Patrick Molloy" wrote:

probably zero basedinstead of
UserForms(1).
try
me.




"monir" wrote:

Hi;

The user form, frmOptSelect, has a number of frames, each with a
number of
option controls. The algoritms for all combinations of options are
not
currently available, so I'm disabling certain options for now.
I'm trying to make sure that an option is selected in each frame on
the form
before I click the btnOpen button. In:

Private Sub btnOpen_Click () event procedure and right at the top,
I
inserted:
....... CheckOptions
which is a regular macro:

Sub CheckOptions()
Dim myOption As Control
Dim myFlag As Integer
.................................................. ...
' check options in frame grpSeries
For Each myOption In UserForms(1).grpSeries.Controls
.....If myOption.Value = True Then myFlag = 1
Next myOption
If myFlage < 1 Then MsgBox "Select B- or GEL-Series"
.................................................. ....
' repeat for all frames
.................................................. ....

I got " Run-time error '9': Subscript out of range", and the above
For Each
statement is higlighted!

Any suggestions ? Thank you




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
ProtectSheet Options are un-checking after macro Roady Excel Discussion (Misc queries) 9 November 16th 11 04:19 PM
SumProduct - checking for multiple options in one column edeaston Excel Discussion (Misc queries) 2 January 30th 09 04:56 PM
Are Error-Checking rules (in Excel Options) workbook-specific? JoeM Excel Discussion (Misc queries) 7 May 4th 08 01:30 AM
Error Checking Options - 2000-2003 brianbishop Excel Discussion (Misc queries) 1 August 11th 06 09:33 PM
spell checking options dvs_47 Excel Worksheet Functions 2 March 6th 06 09:16 PM


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