我的VBA代码存在一些问题。 这就是我想要做的事情:
我知道代码到目前为止部分是硬编码的并且有些臃肿,但请忽略它。
当我运行vba时,我在高级过滤器行中收到运行时错误438.(不支持属性或方法)。
这是我的代码:
Public strFileName As String
Public currentWB As Workbook
Public dataWB As Workbook
Public strCopyRange As String
Public rngFiltro As Variant
Sub PrendiDati()
Dim strListSheet As String
Dim rngFonte As Variant
strListSheet = "input"
'On Error GoTo ErrH
Application.Calculation = xlCalculationManual
ActiveWorkbook.Worksheets("SCADENZIARIO").Range("A2:R15000").Clear
Sheets(strListSheet).Select
Range("b6").Select
'this is the main loop, we will open the files one by one and copy their data into the masterdata sheet
Set currentWB = ActiveWorkbook
strFileName = ActiveCell.Offset(0, 1) & ActiveCell.Value
strCopyRange = ActiveCell.Offset(0, 2) & ":" & ActiveCell.Offset(0, 3)
strWhereToCopy = ActiveCell.Offset(0, 4).Value
strStartCellColName = Mid(ActiveCell.Offset(0, 5), 2, 1)
Application.Workbooks.Open strFileName, UpdateLinks:=False
Set dataWB = ActiveWorkbook
dataWB.Worksheet(1).Range("Database").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=currentWB.Sheets("SCADENZIARIO").Range("A1")
Application.CutCopyMode = False
dataWB.Close False
Sheets(strListSheet).Select
Exit Sub
答案 0 :(得分:0)
您的代码中有拼写错误:
dataWB.Worksheet(1)
应该是:
dataWB.Worksheets(1)
错误引发,因为Worksheet
对象现在有Workbook
属性/方法。