excel确认自动生成VBA的方法如何表出库单里填写的A2:F3的内容用VBA,自动生成到表流水明

2025-03-26 06:52:31
推荐回答(2个)
回答1:

将下现有代码复制到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

回答2:

没看懂,到底要做什么呢?