|
本帖最后由 ys_zheng 于 2015-12-13 12:31 编辑
以下是窗体上"确定"按钮的代码,要把窗体上的数据保存到sheet13工作表的对应列上,但总是无法录入到sheet13,只能录入到窗体所在的工作表,麻烦老师们帮我看看,错在哪里?
Private Sub CommandButton1_Click()
Dim xrow As Integer
With Sheet13
xrow = Sheets("人事异动记录").Range("A1").CurrentRegion.Rows.Count + 1
Cells(xrow, "A") = Sheets("信息录入").Cells(6, 6)
Cells(xrow, "B") = Sheets("信息录入").Cells(6, 8)
Cells(xrow, "C") = Sheets("信息录入").Cells(6, 10)
Cells(xrow, "D") = Sheets("信息录入").Cells(8, 6)
Cells(xrow, "E") = Sheets("信息录入").Cells(21, 4)
Cells(xrow, "F") = ComboBox2.Value
Cells(xrow, "G") = ComboBox3.Value
Cells(xrow, "H") = TextBox1.Value
Cells(xrow, "I") = ComboBox1.Value
Cells(xrow, "J") = ComboBox4.Value
Cells(xrow, "K") = TextBox2.Value
Cells(xrow, "L") = TextBox3.Value
Cells(xrow, "M") = TextBox4.Value
Cells(xrow, "N") = TextBox5.Value
Cells(xrow, "O") = TextBox6.Value
Cells(xrow, "") = TextBox7.Value
Cells(xrow, "Q") = TextBox8.Value
Cells(xrow, "R") = TextBox9.Value
Cells(xrow, "T") = TextBox10.Value
Cells(xrow, "U") = TextBox11.Value
Cells(xrow, "V") = TextBox12.Value
Cells(xrow, "W") = TextBox13.Value
End With
End Sub
本人初学VBA,所以代码写得有点头痛,请各位将就着帮忙看一下无法录入到sheet13工作中,只能录入到窗体所在的工作表,也没有提示错误,应该是我少了什么。
Cells(xrow, "A") = Sheets("信息录入").Cells(6, 6)
所有这个CELLS前面都加一个点( .)试试
|
|