InputBoxes & Ranges
Excellent & quite detailed explanation Per!
Thanx!
However, the message boxes do appear after your recommended macro.
Thanx again man!
--
Best Regards,
Faraz
"Per Jessen" wrote:
Hi
Two things:
You have to declare the variables as variant, to allow user to press
cancel. And you need an error handler as the Set statement require a Object
(could be a range, but not a blank).
Also you MsgBox statements will never show. Look at the code below:
Sub CHECK()
Dim FIRST As Variant, SECOND As Variant, THIRD As Variant
On Error Resume Next
Set FIRST = Application.InputBox("FIRST!", , , , , , , 8)
If FIRST.Address = "" Then
Exit Sub
End If
MsgBox "--:" & FIRST.Address & ":--"
Set SECOND = Application.InputBox("SECOND!", , , , , , , 8)
If SECOND.Address = "" Then
Exit Sub
End If
MsgBox "--:" & SECOND.Address & ":--"
Set THIRD = Application.InputBox("THIRD", , , , , , , 8)
If THIRD.Address = "" Then
Exit Sub
End If
MsgBox "--:" & THIRD.Address & ":--"
On Error GoTo 0 ' reset error handler
End Sub
Regards,
Per
"Faraz A. Qureshi" skrev i
meddelelsen ...
Dear Friends,
I posted this question last week. Although a friend tried to help he
couldn't do so. Sure would oblige if any1 else could help me outta this
mess:
I always get into a trouble when referring to a range via an inputbox and
a
Cancel button is clicked or it is left Blank. Any suggestions?
Furthermore, what might be wrong with the following code?
Sub CHECK()
Dim FIRST As Range, SECOND As Range, THIRD As Range
Set FIRST = Application.InputBox("FIRST!", , , , , , , 8)
If FIRST.Address = "" Then
Exit Sub
MsgBox "--:" & FIRST.Address & ":--"
End If
Set SECOND = Application.InputBox("SECOND!", , , , , , , 8)
If SECOND.Address = "" Then
Exit Sub
MsgBox "--:" & SECOND.Address & ":--"
End If
Set THIRD = Application.InputBox("THIRD", , , , , , , 8)
If THIRD.Address = "" Then
Exit Sub
MsgBox "--:" & THIRD.Address & ":--"
End If
End Sub
--
Best Regards,
Faraz
|