-1
下面是代碼不刷新,我有這樣的形式和2點組合框的2個文本框的和當我改變它刷新平衡債務人組合框,但不一些模糊的原因刷新價格;價格是債務人和數量的交叉參考。文本框在用戶窗體當我改變ComboBox2價值
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