在Excel中递增单元格行 [英] Incrementing cell row in excel
本文介绍了在Excel中递增单元格行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个用户窗体,该窗体将字段中的数据提交到A,B和C列,但是每次用户点击提交时,我都需要它向下移动并填写下一个空行.
I have a UserForm that's going to submit data from the fields to columns A, B, and C, but I need it to move down and fill in the next empty row every time a user hits submit.
到目前为止,这是我所拥有的,我不知道要投入什么才能使它从A2/B2/C2变为A3/B3/C3等.
This is what I have so far, I don't know what I would put in to make it so it would go from A2/B2/C2 to A3/B3/C3, etc.
Private Sub Submit_Click()
Dim LastRow As Object
Set LastRow = Sheet1.Range("a65536").End(xlUp)
Sheet1.Range("A2").Value = MatchNum.Text
Sheet1.Range("B2").Value = TeamNum.Text
Sheet1.Range("C2").Value = AllianceTeamNum.Text
MsgBox "One record written to Sheet1"
End Sub
我是Visual Basic的一个完整的初学者(大约1个小时的经验),如果解决方案尽可能简单,那就太好了.任何帮助将非常感激!
I'm a complete beginner at Visual Basic (approx. 1 hr. of experience) and it'd be nice if the solution is as simple as possible. Any help would be much appreciated!
推荐答案
尝试以下代码:
Private Sub Submit_Click()
With Sheet1
.Select
Dim LastRow As Long
LastRow = .Range("A65536").End(xlUp).Row + 1
.Range("A" & LastRow).Value = MatchNum.Text
.Range("B" & LastRow).Value = TeamNum.Text
.Range("C" & LastRow).Value = AllianceTeamNum.Text
End With
MsgBox "One record written to Sheet1"
End Sub
这篇关于在Excel中递增单元格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文