View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Kilmer Bob Kilmer is offline
external usenet poster
 
Posts: 280
Default How best to extend user's options?

Stuart,
Use three option buttons in a frame on a userform with two buttons - OK,
Cancel. See working sample code below. (I built it in the affirmative. You
can just as well turn it around to skip one or the other or both.)

'---------------------------------------
'Put this in a standard module
Option Explicit
Public mblnStartedWithMain As Boolean

Sub Main()
mblnStartedWithMain = True
Load UserForm1
With UserForm1
.Tag = ""
Call .Show
If .Tag = "ok" Then
Select Case True
Case .optZeros.Value
MsgBox "Do zeros"
'call zeros routine here
Case .optEmpties.Value
MsgBox "Do empties"
'call empties routine here
Case .optBoth.Value
MsgBox "Do both"
'call both here
End Select
Else
'user canceled
End If
End With
Unload UserForm1
End Sub

'---------------------------------------
'Put this in userform module.
'Expects three option buttons
'named optZeros, optEmpties, optBoth *in a frame*
'on a userform named UserForm1
'with two command buttons named
'cmdOK and cmdCancel.

Option Explicit

Private Sub cmdCancel_Click()
Me.Hide
Me.Tag = "cancel"
End Sub

Private Sub cmdOK_Click()
Me.Hide
Me.Tag = "ok"
End Sub

Private Sub UserForm_Activate()
If Not mblnStartedWithMain Then
Unload Me
MsgBox "Start program using Sub Main"
Else
optBoth.Value = True
End If
End Sub



--
Bob Kilmer


"Stuart" wrote in message
...
I currently use the following code to ask user if they wish
to print pages that have been previously totalled as '0.00'.

'Ask user if they want to print zero pages
Msg = "Do you want to print pages that total 0.00" & _
vbNewLine & _
"in the worksheet: " & ActiveSheet.Name & " ?"
Style = vbYesNo + vbDefaultButton2
Title = ActiveWorkbook.Name
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
PrintZeroPages = True
Else '''probably redundant since DefaultButton2 ?
PrintZeroPages = False
End If

A later test on 'PrintZeroPages' will decide whether to
exclude a particular range from the print routine, or not.

However, if the sheet has NOT been previously
calculated, then the particular cells in question will not
hold '0.00'......they will be Empty, and therefore these
empty ranges will also print.

What I'd like to ask user is:

i) Do you want to skip pages totalling '0.00'
ii) Do you want to skip pages where the total is Empty
iii) Do you want to skip both '0.00' and Empty

How can I best construct this, please?

Regards


How best to achieve the following, please:?

Regards.


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.505 / Virus Database: 302 - Release Date: 30/07/2003