drop down menus

E

Ewing25

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)
 
O

Office_Novice

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"?
 
O

Office_Novice

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top