选择标题和过滤器在CSV文件中应用后的第一个可见单元格



我正在尝试从Excel通过VBA打开CSV文件,过滤它并检查标题为空或不空后列J中的第一个单元格。这是目前为止的代码

With wsDest
Sheets("ClustersBU").Range("$a$1:$j$1").AutoFilter Field:=10, Criteria1:=idevent
Sheets("ClustersBU").Range("a" & .Offset(1, 0).SpecialCells(xlCellTypeVisible) (1).Row).Select
End with

第一行正确过滤CSV文件,第二行一直给我一个错误:对象不支持此属性或方法。我尝试了不同的解决方案,但没有工作,因为我不是一个vba专家,我想寻求帮助。

谢谢你,

看来我从根本上解决了这个问题。而不是"从头开始"。如果有人有同样的需求,我将把解决方案贴出来。

Sub Import_Cluster_External()
Application.ScreenUpdating = False
Dim data As Range
Dim wsDest, wsMain As Workbook
Set wsMain = ThisWorkbook
idevent = xyz
Set wsDest = Workbooks.Open("C:Users...***.CSV")
With wsDest
Sheets("ClustersBU").Range("$a$1:$k$1").AutoFilter Field:=11, Criteria1:=idevent

lastRow = Sheets("ClustersBU").Cells(Sheets("ClustersBU").Rows.Count, 10).End(xlUp).Row
ideventcheck = Range("k" & lastRow)

If ideventcheck = idevent Then
MsgBox "clusters found"

Else
MsgBox "Clusters not found "

End If
End With
wsDest.Close (False)

End Sub

希望对你有用。

干杯!

相关内容

最新更新