如何通过单击按钮将值添加到Excel表中?

时间:2013-02-19 10:28:08

标签: excel excel-vba userform vba

我需要填写目录。

我想为此输入Userform,点击add new product中的按钮Textboxes将插入特定列

Private Sub CommandButton1_Click()

 Sheet3.Cells.Rows.Insert
 Sheet3.Cells(25, 27).Value = TextBox1.Value



End Sub

1 个答案:

答案 0 :(得分:2)

这是你在尝试的吗?

Private Sub CommandButton1_Click()
    With Sheet3
        '~~> Insert row at the 25th row.
        .Rows(25).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
        '~~> Add textbox value
        .Cells(25, 27).Value = TextBox1.Value
    End With
End Sub