嗨我知道这可能听起来很容易,但由于我是VBA的新手,因此我需要一些帮助来调整下面的用户表单vba代码,以便在新行中插入组合框下拉列表值。目前我有一个添加命令按钮,它将用户表单上的所有输入添加到找到的新行。我现在面临的当前问题是我需要在add命令按钮中对comboBox行“.Text”进行调整,以使其顺利运行。在我所拥有的代码下面,我已经评论了我现在面临问题的路线。
Private Sub CommandAddButton1_Click()
Dim sh As Worksheet: Set sh = ThisWorkbook.Sheets("Program Status Summary")
Dim emptyRow As Integer: emptyRow = 1 + sh.UsedRange.Find(ComboBoxProjSizes.Text).End(xlDown).Row
With sh
.Cells(emptyRow, "A").Value = 1 + Application.Max(.Columns(1)) ' to generate a new identifier in column 1
.Cells(emptyRow, "B").Value = TextBoxProjCode.Text
.Cells(emptyRow, "C").Value = TextBoxProjName.Text
.Cells(emptyRow, "D").Value = TextBoxSector.Text
.Cells(emptyRow, "E").Value = TextBoxObjective.Text
.Cells(emptyRow, "H").Value = TextBoxProjSponsor.Text
.Cells(emptyRow, "G").Value = TextBoxProjSponsorNew.Text
.Cells(emptyRow, "F").Value = TextBoxProjM.Text
.Cells(emptyRow, "T").Value = TextBoxRegulatory.Text
.Cells(emptyRow, "N").Value = TextBoxRiskLvl.Text
.Cells(emptyRow, "M").Value = TextBoxDatePar.Text
.Cells(emptyRow, "J").Value = TextBoxCostPar.Text
.Cells(emptyRow, "O").Value = TextBoxAffectCust.Text
.Cells(emptyRow, "Q").Value = TextBoxCustNonRetail.Text
.Cells(emptyRow, "P").Value = TextBoxCustRetail.Text
.Cells(emptyRow, "S").Value = TextBoxOutsourcingImp.Text
.Cells(emptyRow, "R").Value = TextBoxKeyStatus.Text
.Cells(emptyRow, "K").Value = TextBoxSchStart.Text
.Cells(emptyRow, "L").Value = TextBoxSchEnd.Text
.Cells(emptyRow, "V").Value = ComboBoxRagSchedule.Text 'Not Sure what to change the word ".Text" to so that the value in the comboBox would appear in the cell'
.Cells(emptyRow, "U").Value = ComboBoxRagFinancial.Text'Not sure what to change the word ".Text" to so that the value in the comboBox would appear in the cell'
.Cells(emptyRow, "W").Value = ComboBoxRagBenefit.Text'Not sure what to change the word ".Text" to so that the value in the comboBox would appear in the cells )
.Cells(emptyRow, "I").Value = TextBoxCost.Text
.Rows(emptyRow + 1).Insert
End With
Unload AddProject
End Sub
非常感谢任何帮助。谢谢:))