Assume you fill your combobox with data from Sheet1!A11:A110
Private Sub Combobox1_Click()
Dim rng as Range, rng1 as Range
Dim res as Variant
With Worksheets("Sheet1")
set rng = .Range("A11:A110")
End With
res = Appliction.Match(Combobox1.Value,rng,0)
if not iserror(res) then
set rng1 = rng(res).Offset(0,1)
if isnumeric(Userform1.Textbox1.Value) then
rng1.Value = rng1.Value & cDbl(Userform1.Textbox1.Value)
Userform1.Textbox2.Value = rng1.Value
end if
End if
End Sub
--
Regards,
Tom Ogilvy
"dawn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hey...
> So I am having a lot of trouble writing a code for excel vba. I
> created a user form with a combo box, two textboxes, and a button. I
> figured out how to fill the combobox when the form loads already. I
> have a worksheet in excel with a column for descriptions and a column
> with the quanity corresponding to each item description. What I am
> trying to do, is when the user selects an option from the
> combobox(which is populated with the item description), and enters a
> quantity in the first textbox, I want excel to add that quantity to the
>
> corresponding quantity of the description already listed. I need it to
>
> add the quanity to the corresponding excel cell and to the second
> textbox on the form. I hope I explained what I am looking for clearly.
>
> THanks in advance for any help as I am seriously stuck!
>
|