Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 923|回复: 1

数据保存重复提示

[复制链接]
发表于 2022-10-4 01:01 | 显示全部楼层 |阅读模式
Sub baocun()
On Error Resume Next
Dim arr, ar, i As Long, j As Long, str As String
str = Sheets("走读登记窗口").Range("C2").Value
arr = Sheets("走读库").Range("c:c").CurrentRegion
For i = 1 To UBound(arr)
    If Dir(arr) <> str Then

        With Sheets("走读登记窗口")
         ar = Array(.[i2], .[c2], .[c4], .[c6], .[g4], .[g6], .[g8], .[g10], .[a20], .[c20], .[e20], .[g20], .[i20])
        End With
        With Sheets("走读库")
         .Range("b65536").End(3).Offset(1, 0).Resize(1, 12) = ar

         End With
         MsgBox "已加入走读列表"
    ElseIf Dir(arr) = str Then

        With Sheets("走读登记窗口")
         ar = Array(.[i2], .[c2], .[c4], .[c6], .[g4], .[g6], .[g8], .[g10], .[a20], .[c20], .[e20], .[g20], .[i20])
        End With
        With Sheets("走读库")
         .Range("b65536").End(3).Offset(1, 0).Resize(1, 12) = ""

         End With
    MsgBox "已存在走读列表"
    End If
Exit For
Next

End Sub

问题所在

问题所在
excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2022-10-5 12:53 | 显示全部楼层
没有附件很难测试,而且这个编写也有问题的
Sub baocun()
On Error Resume Next
Dim arr, ar, i As Long, j As Long, str As String
str = Sheets("走读登记窗口").Range("C2").Value
arr = Sheets("走读库").Range("c:c").CurrentRegion
For i = 1 To UBound(arr)
    If Dir(arr) = str Then exit sub
     MsgBox "已存在走读列表"
    else
        With Sheets("走读登记窗口")
         ar = Array(.[i2], .[c2], .[c4], .[c6], .[g4], .[g6], .[g8], .[g10], .[a20], .[c20], .[e20], .[g20], .[i20])
        End With
        With Sheets("走读库")
         .Range("b65536").End(3).Offset(1, 0).Resize(1, 12) = ar
         End With
         MsgBox "已加入走读列表"
    End If
Next
End Sub
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-3-28 23:15 , Processed in 0.361104 second(s), 10 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表