PDA

View Full Version : Application.InpuBox restriction - input 1 cell



midimax
08-25-2010, 10:24 AM
Hi,

I use Application.InpuBox metod for input of cell address to TextBox placed on UserForm.

My code is:


Dim tbrObjekty1 as TextBox
Dim PomBunka As Range

On Error GoTo 0
On Error Resume Next

Set PomBunka = Nothing
Set PomBunka = Application.InputBox("Select one Cell", "Input", Type:=8)

If Not (PomBunka Is Nothing) Then
tbrObjekty1.Text = PomBunka(1, 1).Address(RowAbsolute:=False, ColumnAbsolute:=False)
End If
I'd like allow user to choose 1 cell only. I guess there could be 2 ways to achieve that:

1. some way restict Application.InputBox to return just 1 cell
2. freeze mouse motion on MouseDown event during Application.InputBox is active

But I don't know how (and I don't want to use RefEdit control)
Does anyone know an answer?

GTO
08-25-2010, 10:33 AM
Untested; maybe:


If Not (PomBunka Is Nothing) Then
If PomBunka.Cells.Count > 1 Then
MsgBox "No Dice!"
Exit Sub
End If

tbrObjekty1.Text = PomBunka(1, 1).Address(RowAbsolute:=False, ColumnAbsolute:=False)
End If