ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   drop down menus (https://www.excelbanter.com/excel-programming/410235-drop-down-menus.html)

Ewing25

drop down menus
 
Ok what I want to do is make a drop down menu with the same values that they
input in a different worksheet. However i dont want there to be duplicates in
the drop down list if they put the same value in twice.

Im going to have a userform made with a drop down list for the values they
input in a previous worksheet and another field called miles that they put in
themselves. When they click on commandbutton1 it will input those fields into
A2 and B2 then will clear the userform to input again. If they push
commandbutton2 it will end the macro.

Inputworksheet: Miles
Worksheet with values for dropdown: Expense (Column H)



Office_Novice

drop down menus
 
I am a little confused as to what your trying to accomplish. You want the
user to add items to a dropdown? or select from one or both? What information
is going to "miles"?

"Ewing25" wrote:

Ok what I want to do is make a drop down menu with the same values that they
input in a different worksheet. However i dont want there to be duplicates in
the drop down list if they put the same value in twice.

Im going to have a userform made with a drop down list for the values they
input in a previous worksheet and another field called miles that they put in
themselves. When they click on commandbutton1 it will input those fields into
A2 and B2 then will clear the userform to input again. If they push
commandbutton2 it will end the macro.

Inputworksheet: Miles
Worksheet with values for dropdown: Expense (Column H)



Office_Novice

drop down menus
 
Maybe somthing like this will get you started in the right direction. You
will need a userform, 2 command buttons a combobox and a textbox, I used you
sheet names to keep it easy. HTH

Option Explicit

Private Sub CommandButton1_Click()
Dim RW As Long
Dim WS As Worksheet
Set WS = Worksheets("Miles")

'Finds first empty row
RW = WS.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'Fits columns to contents
Columns("A").AutoFit
Columns("B").AutoFit

' Adds Values to Worksheet "Miles"
WS.Cells(RW, 1).Value = Me.ComboBox1.Value
WS.Cells(RW, 2).Value = Me.TextBox1.Value

' Clears data
Me.ComboBox1.Value = ""
Me.TextBox1.Value = ""

End Sub

Private Sub CommandButton2_Click()
Unload Me
End Sub

Private Sub UserForm_Initialize()
With Me.ComboBox1
.RowSource = "Expense!H1:H10" ' Populates Dropdown from "Expense" Column H
End With
End Sub


"Office_Novice" wrote:

I am a little confused as to what your trying to accomplish. You want the
user to add items to a dropdown? or select from one or both? What information
is going to "miles"?

"Ewing25" wrote:

Ok what I want to do is make a drop down menu with the same values that they
input in a different worksheet. However i dont want there to be duplicates in
the drop down list if they put the same value in twice.

Im going to have a userform made with a drop down list for the values they
input in a previous worksheet and another field called miles that they put in
themselves. When they click on commandbutton1 it will input those fields into
A2 and B2 then will clear the userform to input again. If they push
commandbutton2 it will end the macro.

Inputworksheet: Miles
Worksheet with values for dropdown: Expense (Column H)




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

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