Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Here's what I came up with:
First, in a module, paste the following code: Sub CountRange() Dim CellCount As Integer CellCount = Selection.Count If CellCount <= 1 Then UserForm1.Show End If End Sub Then create a UserForm with a RefEdit control and a CommandButton (RefEdit1 and CommandButton1). Double click the command button to bring up the default CommandButton1_Click code and paste the following between the Private Sub and End Sub lines: Dim SetRange As Range MsgBox RefEdit1.Value Range(RefEdit1.Value).Select Set SetRange = ActiveWindow.RangeSelection ActiveSheet.PageSetup.PrintArea = SetRange.Address Basically the CountRange counts the number of cells selected on the worksheet and if less than 2 cells are selected pops up the form. The form has a RefEdit control that allows the user to select a range on the worksheet. When the CommandButton is pressed, the variable SetRange is set to the range selected in RefEdit then the PrintArea is set. HTH Mike. -- Michael J. Malinsky "Andy" wrote in message ... I am trying to write a routine that asks the user to set a print area if one has not already been set. At the start of the routine, I have used this code; If ActiveSheet.PageSetup.PrintArea = "" Then Load UserForm1 UserForm1.Show End If However, this doesn't seem to work if a range is selected for printing. Is there a way to check whether "a range has been selected and if not prompt the user to do so"? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Message "user defined type not defined" | Excel Discussion (Misc queries) | |||
user defined function | Excel Worksheet Functions | |||
"User-defined type not defined" message in Excel | Excel Discussion (Misc queries) | |||
User Defined Functions | Excel Worksheet Functions | |||
User Defined Functions | Excel Worksheet Functions |