Excel VBA recordset.open 命令返回两倍的记录数
该代码已经运行多年,现在我们升级到 Windows 10 和 Excel 2016,它正在执行此操作。
答案1
由于错误地输入了重复记录(as you have written in Comments above
),因此,您可以读取唯一的记录,而不是删除记录。
以下是一些可能有助于获取唯一记录的 VBA 代码行。
rs.Open "SELECT Distinct ColumnName AS C FROM TableName
或者
strSQL = "SELECT Distinct(COLNAME) from [SheetName$] "