excel 按钮控件 sheet1中某些单元格中的内容记入sheet2中的对应位置
你好,这是我上午提的问题,以下是您的回答,对我很有帮助PrivateSubCommandButton1_Click()r=Sheet2.[A65536].End(xlUp...
你好,这是我上午提的问题,以下是您的回答,对我很有帮助
Private Sub CommandButton1_Click()
r = Sheet2.[A65536].End(xlUp).Row
Sheet2.Cells(r + 1, 1) = Sheet1.[B4] 'B4和C4是sheet1表输入姓名和年龄的单元格
Sheet2.Cells(r + 1, 2) = Sheet1.[C4]
Sheet1.[B4].Clear
Sheet1.[C4].Clear
End Sub
现在有一个新问题,我一次填写多人信息,比如张三和李四,年龄分别是16和15,按照上面的思路
我写了如下语句
Private Sub CommandButton1_Click()
r = Sheet2.[A65536].End(xlUp).Row
Sheet2.Cells(r + 1, 1) = Sheet1.[B4]
Sheet2.Cells(r + 1, 2) = Sheet1.[C4]
Sheet2.Cells(r + 1, 1) = Sheet1.[B5]
Sheet2.Cells(r + 1, 2) = Sheet1.[C5]
Sheet1.[B4].Clear
Sheet1.[C4].Clear
End Sub
但是李四的数据会覆盖张三的数据,而不是我想象的保存两条记录。请问如何解决 展开
Private Sub CommandButton1_Click()
r = Sheet2.[A65536].End(xlUp).Row
Sheet2.Cells(r + 1, 1) = Sheet1.[B4] 'B4和C4是sheet1表输入姓名和年龄的单元格
Sheet2.Cells(r + 1, 2) = Sheet1.[C4]
Sheet1.[B4].Clear
Sheet1.[C4].Clear
End Sub
现在有一个新问题,我一次填写多人信息,比如张三和李四,年龄分别是16和15,按照上面的思路
我写了如下语句
Private Sub CommandButton1_Click()
r = Sheet2.[A65536].End(xlUp).Row
Sheet2.Cells(r + 1, 1) = Sheet1.[B4]
Sheet2.Cells(r + 1, 2) = Sheet1.[C4]
Sheet2.Cells(r + 1, 1) = Sheet1.[B5]
Sheet2.Cells(r + 1, 2) = Sheet1.[C5]
Sheet1.[B4].Clear
Sheet1.[C4].Clear
End Sub
但是李四的数据会覆盖张三的数据,而不是我想象的保存两条记录。请问如何解决 展开
展开全部
Private Sub CommandButton1_Click()
r = Sheet2.[A65536].End(xlUp).Row
Sheet2.Cells(r + 1, 1) = Sheet1.[B4]
Sheet2.Cells(r + 1, 2) = Sheet1.[C4]
Sheet2.Cells(r + 2, 1) = Sheet1.[B5]
Sheet2.Cells(r + 2, 2) = Sheet1.[C5]
Sheet1.[B4:C5].Clear
End Sub
这是一次性输入两行的.
改进的代码可以适用于任意情况,1-N行数据都可以:
Private Sub CommandButton1_Click()
r = Sheet2.[A65536].End(xlUp).Row
Sheet1.[B4].CurrentRegion.Copy Sheets("Sheet2").Cells(r + 1, 1)
Sheet1.[B4].CurrentRegion.Clear
End Sub
来自:求助得到的回答
展开全部
Private Sub CommandButton1_Click()
r = Sheet2.[A65536].End(xlUp).Row
Sheet2.Cells(r + 1, 1) = Sheet1.[B4]
Sheet2.Cells(r + 1, 2) = Sheet1.[C4]
Sheet2.Cells(r + 2, 1) = Sheet1.[B5]
Sheet2.Cells(r + 2, 2) = Sheet1.[C5]
Sheet1.range("B4:C5").Clear
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2014-07-17 · 知道合伙人软件行家
关注
展开全部
Private Sub CommandButton1_Click()
r = Sheet2.[A65536].End(xlUp).Row
arr= Sheet1.Range("B4:C" & Sheet1.[B65536].End(xlUp).Row)
Sheet2.Cells(r + 1, 1).ReSize(Ubound(arr),Ubound(arr,2))=arr
Sheet1.Range("B4:C" & Sheet1.[B65536].End(xlUp).Row).ClearContents
End Sub
r = Sheet2.[A65536].End(xlUp).Row
arr= Sheet1.Range("B4:C" & Sheet1.[B65536].End(xlUp).Row)
Sheet2.Cells(r + 1, 1).ReSize(Ubound(arr),Ubound(arr,2))=arr
Sheet1.Range("B4:C" & Sheet1.[B65536].End(xlUp).Row).ClearContents
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询