edit in userform-combobox

xam99

New Member
Joined
Jan 19, 2021
Messages
11
Office Version
  1. 2007
Platform
  1. Windows
Hi to all
edit in userform-combobox
VBA Code:
Option Explicit

Private Sub cmdCancel_Click()
'Unload the userform
    Unload Me
End Sub

Private Sub cmdOkay_Click()
'Verify that an item was selected
    If Me.ComboBox1.BoundValue = vbNullString Then
        MsgBox "You did not choose an item!", vbOKOnly
    Else
        MsgBox "You choose " & Me.ComboBox1.BoundValue, vbOKOnly
    End If
    Unload Me
End Sub

Private Sub UserForm_Initialize()
'Load the combobox with a variety of household pets
    With Me.ComboBox1
        .AddItem ("Cat")
        .AddItem ("Dog")
        .AddItem ("Bird")       
    End With
End Sub


if cat insert in cell B10 cat
if dog insert in cell B11 dog
if bird insert in cell B12 bird

thank you
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try with this version:
VBA Code:
Private Sub cmdOkay_Click()
'Verify that an item was selected
    If Me.ComboBox1.BoundValue = vbNullString Then
        MsgBox "You did not choose an item!", vbOKOnly
    Else
        MsgBox "You choose " & Me.ComboBox1.BoundValue, vbOKOnly
        Sheets("Foglio2").Range("B10").Offset(ComboBox1.ListIndex, 0).Value = ComboBox1.BoundValue
       'Unload Me   'Here?
    End If
    Unload Me      '???
End Sub
Maybe you should insert Unload Me within the Else condition, so that the user can correct his choice
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,525
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top