根据用户表单设置的行范围添加新的信息行

您好我有一个由3个大小的项目(大,中,小项目大小)组成的Excel文件。 我已经根据他们的项目大小在一个Excel表中分开了。 但是,将来我需要根据项目规模增加新的项目。 我需要一个用户表单运行的代码,并根据项目大小添加新的信息。 到目前为止,我只能设法创build一些代码。 然而,它不工作,因为它会发现任何空行并填写,这不是我想要的。 我想要的是一个代码,这将有助于根据项目大小进行select,并从那里插入新的行。 例如,新的项目大小很小,因此项目信息将被插入在小型项目中find的空行中。 这是迄今为止的代码。

Private Sub CommandAddButton1_Click() lastrow = Sheets("Programme Status Summary").Range("J").End(xlDown).Row Cells(lastrow + 1, "J").Value = TextBoxProjCode.Text Cells(lastrow + 1, "E").Value = TextBoxProjName.Text Cells(lastrow + 1, "C").Value = TextBoxSegment.Text Cells(lastrow + 1, "F").Value = TextBoxSummary.Text Cells(lastrow + 1, "G").Value = TextBoxAcc1.Text Cells(lastrow + 1, "H").Value = TextBoxAcc2.Text Cells(lastrow + 1, "I").Value = TextBoxProjM.Text Cells(lastrow + 1, "K").Value = TextBoxCountry.Text Cells(lastrow + 1, "L").Value = TextBoxRegulatory.Text Cells(lastrow + 1, "M").Value = TextBoxRiskLvl.Text Cells(lastrow + 1, "P").Value = TextBoxSchForecast.Text Cells(lastrow + 1, "R").Value = TextBoxSchPar.Text Cells(lastrow + 1, "S").Value = TextBoxImpact.Text Cells(lastrow + 1, "T").Value = TextBoxCustNonRetail.Text Cells(lastrow + 1, "U").Value = TextBoxCustRetail.Text Cells(lastrow + 1, "V").Value = TextBoxOutsourcingImp.Text Cells(lastrow + 1, "W").Value = TextBoxListImpt.Text Cells(lastrow + 1, "X").Value = TextBoxKeyStatus.Text Cells(lastrow + 1, "N").Value = TextBoxSchStart.Text Cells(lastrow + 1, "O").Value = TextBoxSchEnd.Text Cells(lastrow + 1, "Y").Value = TextBoxRagStatus.Text Cells(lastrow + 1, "Z").Value = TextBoxRagCost.Text Cells(lastrow + 1, "AA").Value = TextBoxRagBenefit.Text Unload AddMedProjects End Sub 

我希望任何人都可以帮助我,因为我不擅长这一点。 谢谢!