![](/img/trans.png)
[英]VBA Userform Populate textbox with cell value based on 2 combobox selections
[英]Populate Userform textbox based on cell selected by Combox
在我的Excel文档中,我在两列中包含以下信息:
US Dollar (USD) 1
British Pound (GBP) 0.63
Guatemalan Quetzal (GTQ) 0.13
Honduras Lempira (HNL) 0.046
Other Please give factor
Other Please give factor
Other Please give factor
Other Please give factor
我有一个由第一列填充的组合框:
Private Sub UserForm_Initialize()
CurrencyList.List = Worksheets("MySheet").Range("A23:A30").Value
End Sub|
我想自动在下一列中使用货币换算填充文本框,因此当您在组合框中选择货币时,它会自动填充文本框,因此您可以按照建议保留它,也可以根据需要进行更改。 我在Mac上使用excel2011。我遇到的所有解决方案似乎都适用于Windows,并且出现错误,提示我调用的方法不存在。
这应该使您入门。 它使用您的值(您已经拥有)填充表单组合框,并且Vlookup在组合框中找到与值相关联的货币。 仔细检查您的ComboBox和TextBox Name属性是否与您的代码匹配。
Private Sub UserForm_Initialize()
ComboBox1.List = Worksheets("Sheet1").Range("A23:A30").Value
End Sub
Private Sub ComboBox1_Change()
TextBox1.Text = Application.VLookup(ComboBox1.Value, Worksheets("sheet1").Range("A23:B27"), 2, False)
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.