ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ListBox with use like inputbox (https://www.excelbanter.com/excel-programming/317642-listbox-use-like-inputbox.html)

kraljb[_3_]

ListBox with use like inputbox
 

Hello and thank you in advance for your help,

The issue that I am having is that I need a listbox to come up in th
place of an inputbox. I am new to VBA, and cannot seem to figure thi
out.

The exact issue is that I have a form that is filled out with mainl
string entrys, however there are a few fields that are forced from
list. I am working on a secondary form to edit that information
however I would like to still force one of the pre-established choices
and need a listbox to pop up rather than an inputbox for those specifi
entries.

I am not very good at explaining my issues, so if you need mor
information, please let me know.

Thank you,

Joh

--
kralj
-----------------------------------------------------------------------
kraljb's Profile: http://www.excelforum.com/member.php...nfo&userid=995
View this thread: http://www.excelforum.com/showthread.php?threadid=31991


Joaquim Fernandes

ListBox with use like inputbox
 
kraljb wrote in message ...
Hello and thank you in advance for your help,

The issue that I am having is that I need a listbox to come up in the
place of an inputbox. I am new to VBA, and cannot seem to figure this
out.

The exact issue is that I have a form that is filled out with mainly
string entrys, however there are a few fields that are forced from a
list. I am working on a secondary form to edit that information,
however I would like to still force one of the pre-established choices,
and need a listbox to pop up rather than an inputbox for those specific
entries.

I am not very good at explaining my issues, so if you need more
information, please let me know.

Thank you,






Hi !
John
Try This ;
First Open the VBA editor add a userForm and create a listbox, then in
your VBA project "This WorkBook" add your code, (this code shows the
months in a comb box)

This code must be placed in "thisWorkbook"


Private Sub Workbook_Open()
UserForm1.ComboBox1.AddItem "Janeiro"
UserForm1.ComboBox1.AddItem "Fevereiro"
UserForm1.ComboBox1.AddItem "Marco"
UserForm1.ComboBox1.AddItem "Abril"
UserForm1.ComboBox1.AddItem "Maio"
UserForm1.ComboBox1.AddItem "Junho"
UserForm1.ComboBox1.AddItem "Julho"
UserForm1.ComboBox1.AddItem "Agosto"
UserForm1.ComboBox1.AddItem "Setembro"
UserForm1.ComboBox1.AddItem "Outubro"
UserForm1.ComboBox1.AddItem "Novembro"
UserForm1.ComboBox1.AddItem "Dezembro"

UserForm1.Show

End Sub

This code must be placed in UserForm

Private Sub CommandButton1_Click()
If UserForm1.ComboBox1 = "Janeiro" Then
Worksheets("Dados").Cells(5, 4) = Val(UserForm1.TextBox1)
UserForm1.TextBox1 = ""
End If

if UserForm1.ComboBox1 = "Fevereiro" Then
Worksheets("Dados").Cells(5, 5) = UserForm1.TextBox1
UserForm1.TextBox1 = ""
End If
End Sub


Hope this helps
Best regards


Joaquim Fernandes


All times are GMT +1. The time now is 11:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com