excel确认自动生成VBA的方法如何表出库单里填写的A2:F3的内容用VBA,自动生成到表流水明
答案:2 悬赏:20 手机版
解决时间 2021-12-22 04:23
- 提问者网友:锁深秋
- 2021-12-21 23:03
excel确认自动生成VBA的方法如何表出库单里填写的A2:F3的内容用VBA,自动生成到表流水明细A2:F3里面呢?要求表流水明细逐行生成
最佳答案
- 五星知识达人网友:渊鱼
- 2021-12-22 00:34
将下现有代码复制到VBA编辑器中,加载在控件里运行就可以了
Sub localdata()
x = 2
Do While Sheet1.Cells(x, 1) <> ""
x = x + 1
Loop
n = 2
If ActiveSheet.Cells(n, 1) = "" Then
MsgBox "内容不完整,请确认!"
Exit Sub
End If
Do While n<= 3
On Error Resume Next
Sheet1.Cells(x, 1) = ActiveSheet.Cells(n,1)
Sheet1.Cells(x, 2 )= ActiveSheet.Cells(n,2)
Sheet1.Cells(x, 3) = ActiveSheet.Cells(n, 3)
Sheet1.Cells(x,4) = ActiveSheet.Cells(n, 4)
Sheet1.Cells(x, 5) = ActiveSheet.Cells(n, 5)
Sheet1.Cells(x, 6) = ActiveSheet.Cells(n, 6)
x = x + 1
n = n + 1
Loop
CommandButton1.TakeFocusOnClick = False
ActiveWorkbook.Save
End Sub
Sub localdata()
x = 2
Do While Sheet1.Cells(x, 1) <> ""
x = x + 1
Loop
n = 2
If ActiveSheet.Cells(n, 1) = "" Then
MsgBox "内容不完整,请确认!"
Exit Sub
End If
Do While n<= 3
On Error Resume Next
Sheet1.Cells(x, 1) = ActiveSheet.Cells(n,1)
Sheet1.Cells(x, 2 )= ActiveSheet.Cells(n,2)
Sheet1.Cells(x, 3) = ActiveSheet.Cells(n, 3)
Sheet1.Cells(x,4) = ActiveSheet.Cells(n, 4)
Sheet1.Cells(x, 5) = ActiveSheet.Cells(n, 5)
Sheet1.Cells(x, 6) = ActiveSheet.Cells(n, 6)
x = x + 1
n = n + 1
Loop
CommandButton1.TakeFocusOnClick = False
ActiveWorkbook.Save
End Sub
全部回答
- 1楼网友:千夜
- 2021-12-22 00:50
没看懂,到底要做什么呢?
再看看别人怎么说的。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯