Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default InputBox using "Data Validation"

Is there any way an InputBox can provide a drop-down list [ie Data
Validation] ?

A range named NumberID [up to six, or possibly a few more rows] should
ideally "drop down" when the InputBox is called.

Thanx,
- Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default InputBox using "Data Validation"

Nope.

But you could create your own userform that does exactly what you want.

If you want to design your own userform:

Debra Dalgleish shares some tips:
http://contextures.com/xlUserForm01.html


MikeF wrote:

Is there any way an InputBox can provide a drop-down list [ie Data
Validation] ?

A range named NumberID [up to six, or possibly a few more rows] should
ideally "drop down" when the InputBox is called.

Thanx,
- Mike


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 173
Default InputBox using "Data Validation"

Ok, I created a user form [frmNumberID] with one ComboBox [cboNumberID].
That's it.

Here is the relevant form code:

Private Sub UserForm_Click()
cboNumberID.Enabled = True
End Sub

Private Sub cboShowID_DropButtonClick()
ActiveCell.Value = Me.cboNumberID.Value
End Sub

Here is the code in the procedure that calls it:
*** navigation to a particular cell, then....
frmNumberID.Show
ActiveCell.Value = cboNumberID

....But although it drops the correct value into the cell, when I click the
form's close box it goes to an error.
Debug says it's this line: ActiveCell.Value = Me.cboNumberID.Value

What am I missing??

Thanx,
- Mike





"Dave Peterson" wrote:

Nope.

But you could create your own userform that does exactly what you want.

If you want to design your own userform:

Debra Dalgleish shares some tips:
http://contextures.com/xlUserForm01.html


MikeF wrote:

Is there any way an InputBox can provide a drop-down list [ie Data
Validation] ?

A range named NumberID [up to six, or possibly a few more rows] should
ideally "drop down" when the InputBox is called.

Thanx,
- Mike


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default InputBox using "Data Validation"

I bet you're unloading the userform when you click the close button (do you have
a dedicated button or are you using the X button in the userform's title bar)?

That means that since the userform is unloaded from memory, there isn't any
userform for VBA to find--and no userform means no combobox named cboNumberID
that exists anymore.

Since you're putting the value in the activecell in teh _dropbuttonclick event,
you could just remove that line of code that's causing the trouble.

=====

As a user, I think I would rather see a dedicated "ok" button that does the real
work. Then I would choose the value from the combobox(es) and then hit the ok
button. If I made a mistake, I wouldn't have to worry about the worksheet
getting bad data.

Option Explicit
Private Sub CommandButton1_Click()
If Me.cboNumberID.ListIndex = -1 Then
'nothing in the combobox
'so don't do anything
Else
ActiveCell.Value = Me.cboNumberID.Value
End If
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
With Me.cboNumberID
.AddItem "a"
.AddItem "b"
.AddItem "c"
End With

With Me.cboShowID
.AddItem "1"
.AddItem "2"
.AddItem "3"
End With

With Me.CommandButton1
.Caption = "Ok"
.Default = True
End With

With Me.CommandButton2
.Caption = "Cancel"
.Cancel = True
End With
End Sub


MikeF wrote:

Ok, I created a user form [frmNumberID] with one ComboBox [cboNumberID].
That's it.

Here is the relevant form code:

Private Sub UserForm_Click()
cboNumberID.Enabled = True
End Sub

Private Sub cboShowID_DropButtonClick()
ActiveCell.Value = Me.cboNumberID.Value
End Sub

Here is the code in the procedure that calls it:
*** navigation to a particular cell, then....
frmNumberID.Show
ActiveCell.Value = cboNumberID

...But although it drops the correct value into the cell, when I click the
form's close box it goes to an error.
Debug says it's this line: ActiveCell.Value = Me.cboNumberID.Value

What am I missing??

Thanx,
- Mike

"Dave Peterson" wrote:

Nope.

But you could create your own userform that does exactly what you want.

If you want to design your own userform:

Debra Dalgleish shares some tips:
http://contextures.com/xlUserForm01.html


MikeF wrote:

Is there any way an InputBox can provide a drop-down list [ie Data
Validation] ?

A range named NumberID [up to six, or possibly a few more rows] should
ideally "drop down" when the InputBox is called.

Thanx,
- Mike


--

Dave Peterson


--

Dave Peterson
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
Validation ?:Accepting both Numbers AND specific letters("N","n"," Antonio Excel Discussion (Misc queries) 2 April 22nd 08 05:07 PM
Validation question - allow -500%, 0%, "=50%*50%" but forbid "A", "", " ", "-" ? tskogstrom Excel Programming 2 November 27th 06 09:50 AM
Data Validation: Allow "List" or "Whole number" monir Excel Programming 1 May 31st 06 04:40 PM
Data Validation: Allow "List" or "Whole number" monir Excel Programming 0 May 31st 06 03:49 PM
Adding "New" "Insert" "Delete" into a workbook to change from data 1 to data 2 etc Bob Reynolds[_2_] Excel Programming 0 March 4th 04 08:52 PM


All times are GMT +1. The time now is 12:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"