怎样使用VBA多表数据录入?
1、首先在开发工具中打开VBA编辑器
2、在单元格区域当中输入一些内容作为例子
3、在VBA编辑器中插入模块
4、在模块当中输入如下代码,然后运行
Private Sub CommandButton1_Click()
If TextBox1 <> "" And TextBox2 <> "" And TextBox3 <> "" And TextBox4 <> "" Then
With Sheets(Me.ComboBox1.Value).Range("a1048576").End(xlUp)
.Offset(1, 0)=Me.TextBox1
.Offset(1, 1)=Me.TextBox2
.Offset(1, 2)=Me.TextBox3
.Offset(1, 3)=Me.TextBox4
End With
Sheets(Me.ComboBox1.Value).Select
Range("a2:d"&Range("a1048576").End(xlUp).Row).Borders.LineStyle=xlContinuous
Else
MsgBox "所有文本框不能为空!", vbOKOnly+64, "提示"
End If
TextBox1=""
TextBox2=""
TextBox3=""
TextBox4=""
TextBox1.SetFocus
End Sub
5、在代码后面输入以下代码,功能是为组合框添加子选项,分别为工作表中所有工作表表名,同时对组合框添加默认显示项目
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:55
阅读量:92
阅读量:48
阅读量:49
阅读量:48