注册 登录
编程论坛 Excel/VBA论坛

VBA数据调取数据重复,不知所措

ds378079379 发布于 2021-09-13 14:10, 5068 次点击
在表1和表2数据调取过程中,新录入数据会重复,求救。

程序代码:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim a As Integer
Dim b As Integer
b = 2
Do
b = b + 1
If Sheet2.Cells(b, 1) = "" Then
Exit Do
End If
Loop
For a = 4 To 3000
   If Sheet1.Cells(a, 13) = "已术" Then
       Sheet2.Cells(b, 1) = Sheet1.Cells(a, 2)
       Sheet2.Cells(b, 2) = Sheet1.Cells(a, 3)
       Sheet2.Cells(b, 3) = Sheet1.Cells(a, 4)
       Sheet2.Cells(b, 4) = Sheet1.Cells(a, 5)
       Sheet2.Cells(b, 5) = Sheet1.Cells(a, 6)
       Sheet2.Cells(b, 6) = Sheet1.Cells(a, 7)
       Sheet2.Cells(b, 7) = Sheet1.Cells(a, 8)
       Sheet2.Cells(b, 8) = Sheet1.Cells(a, 16)
       Sheet2.Cells(b, 9) = Sheet1.Cells(a, 17)
       b = b + 1
      End If
      Next
End Sub

只有本站会员才能查看附件,请 登录
3 回复
#2
zzj379952021-09-13 18:26
如果需要定制VBA 程序 +QQ 56074013
#3
夏虫井蛙2021-09-26 11:31
你的需求说一下
#4
Anfei19792021-12-11 16:51
请和VX18062660488联系。
1