I try to make a macro that looks for a value in a database and that copies data in two columns after the reference.
- In a userform, a drop menu with value "ps86", another with the number "5"
- A submit button
- when I click the button I would get in the database:
Try this code:
ComboBox1 = droplist with value (ps85, ps86 ...)
ComboBox2 = Quantity list
CommandButton1 = The submit button
Adapt the following code:
Private Sub CommandButton1_Click()
Dim RngTrouve As Range
If ComboBox1 <> "" And ComboBox2 <> "" Then
Set RngTrouve = .Cells.Find(ComboBox1.Value, lookat:=xlWhole)
If RngTrouve Is Nothing Then
MsgBox "valeur inexistante"
RngTrouve.Offset(0, 2).Value = ComboBox2.Value
Set RngTrouve = Nothing
Thanks to pijaku for this tip.
Published by aakai1056
Latest update on February 22, 2012 at 09:30 AM by aakai1056.