2010-09-04 4 views
-1

Voici le code, j'ai 2 ComboBox sur ce formulaire et 2 TextBox et pour une raison obscure quand je change le ComboBox débiteur, il Actualise la balance, mais ne rafraîchir le prix; Le prix est une référence croisée du débiteur et de la quantité.Zone de texte sur UserForm ne se rafraîchit pas lorsque je change ComboBox2 Valeur

Private Sub UserForm_Initialize() 

    Purchase_Select_Debtor.List = Workbooks("New Template.xlsm").Worksheets("Debtor_list").Range("A2:A13").Value 
    Purchase_Select_Debtor.ListIndex = 0 

    Purchase_Select_Quantity.List = Workbooks("New Template.xlsm").Worksheets("RangeNames").Range("A15:A20").Value 
    Purchase_Select_Quantity.ListIndex = 0 

End Sub 

Private Sub cmdBuy_Purchase_Click() 

    Purchase_Select_Debtor.Value = Name 
     Purchase_Select_Price.Value = Amount 
    Purchase_Select_Balance.Value = Balance 

    If Name = "" Then 
     MsgBox "Select Debtor" 
     Exit Sub 
    End If 

    DebtorRow = 1 
    Do 
     TempName = Worksheets("Debtor_list").Range("A" & DebtorRow).Value 
     If TempName = Name Then 
      DebtorBalance = CSng(Worksheets("Debtor_List").Range("B" & DebtorRow).Value) 
      Exit Do 
     End If 
     DebtorRow = DebtorRow + 1 
    Loop Until TempName = "" 

    If TempName = "" Then 
     MsgBox "Debtor not found" 
     Exit Sub 
    End If 


    Worksheets("Debtor_List").Range("B" & DebtorRow).Value = DebtorBalance - Amount 

MsgBox "You have just Purchased " & Amount & " For $" & Amount & vbCrLf & "Your Account Balance is now: " & Balance 

End Sub 

Private Sub cmdClose_Purchase_Click() 
    Unload Me 
End Sub 


Private Sub Purchase_Select_Debtor_Change() 

Purchase_Select_Balance.Value = "$" & Application.VLookup(Purchase_Select_Debtor.Value, Sheets("Debtor_list").Range("A2:B13"), 2, 0) 

End Sub 

Private Sub Purchase_Select_Quantity_Change() 

Purchase_Select_Price.Value = "$" & Application.Index(Sheets("Inventory_list").Range("A1:G13"), Application.Match(Purchase_Select_Debtor.Value, Sheets("Inventory_list").Range("A1:A13"), 0), Application.Match(Purchase_Select_Quantity.Value, Sheets("Inventory_list").Range("A1:G1"), 0)) 

End Sub 

Répondre

1

Si vous voulez le prix et l'équilibre à rafraîchir lorsque vous modifiez le Débiteur, puis:

Private Sub Purchase_Select_Debtor_Change() 

    Purchase_Select_Balance.Value = "$" & Application.VLookup(Purchase_Select_Debtor.Value, Sheets("Debtor_list").Range("A2:B13"), 2, 0) 

    Purchase_Select_Price.Value = "$" & Application.Index(Sheets("Inventory_list").Range("A1:G13"), Application.Match(Purchase_Select_Debtor.Value, Sheets("Inventory_list").Range("A1:A13"), 0), Application.Match(Purchase_Select_Quantity.Value, Sheets("Inventory_list").Range("A1:G1"), 0)) 

End Sub 
Questions connexes