|
楼主 |
发表于 2013-1-4 13:00
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Private Sub CommandButton1_Click()
Dim a As Long, m%
a = Sheet2.Range("B65535").End(xlUp).Row + 1
If IsNumeric(Application.Match(TextBox1.Value, Range("B1:B" & a), 0)) Then '如果姓名已存在,则添加信息
m = Application.Match(TextBox1.Value, Range("B1:B" & a), 0) ' 行数
For s = 2 To 9
If Controls("TextBox" & s).Value <> "" Then Cells(m, s + 1) = Controls("TextBox" & s).Value
Next
Else '如果不存在。则追加
Cells(a, 2).Resize(1, 9) = Array(TextBox1.Value, TextBox2.Value, TextBox3.Value, TextBox4.Value, TextBox5.Value, TextBox6.Value, TextBox7.Value, TextBox8.Value, TextBox9.Value)
TextBox1.Value = ""
TextBox1.SetFocus
End If
End Sub
问题已经完美解决,感谢山风老师 |
|