你能告诉我下面的代码有什么问题吗?反复收到错误,如Type Mismatch
下面的代码:
TotalRows=objExcel1.Application.WorksheetFunction.CountA(ob4.Columns(1))
'MsgBox(TotalRows)
ReDim ArrParent(TotalRows - 2)
ArrParent=ob4.Range("A2:" & "A" & TotalRows).Value 'here i am getting an error as said above
'Call to the subroutine
ParentPIDNumber ArrParent,ob3,ob2,ob4
代码
Sub FileredOpenProcessToDel(ob3,ob2,ob4)
Dim ColumnToFilter,TotalRows
Dim rngFilter,cel,str,rangesToRemove,x
Dim strToRemove : strToRemove = ""
Dim ArrParent
objExcel1.ScreenUpdating = False
objExcel1.Calculation = -4135 'xlCalculationManual
ColumnToFilter=objExcel1.Application.WorksheetFunction.CountA(ob4.Rows(1)) - 1
ob4.Range(ob4.Cells(1,ColumnToFilter),ob4.Cells(1,ColumnToFilter)).AutoFilter ColumnToFilter, "Open",,,True
'Dim rngFilter as Range
Set rngFilter = objExcel1.Application.Intersect(ob4.UsedRange,ob4.UsedRange.Offset(1),ob4.Columns(1)).SpecialCells(12)'xlCellTypeVisible
'MsgBox(rngFilter.Rows.Count)
REM Do While 1=1
REM 'Msgbox
REM Loop
'msgbox "Filtered range has " & rngFilter.Rows.Count & " rows."
str=""
For each cel in rngFilter
str = str & (cel.row) & ":" & (cel.row) & ","
Next
rangesToRemove = Split(str,",")
For x = UBOUND(rangesToRemove)-1 To LBOUND(rangesToRemove) Step -1
strToRemove = strToRemove & rangesToRemove(x)
If Len(strToRemove) > 200 then
ob4.Range(strToRemove).delete'str & rangesToRemove(x) & ":" & rangesToRemove(x) & ","
strToRemove = ""
Else
strToRemove = strToRemove & ","
End If
Next
If len(strToRemove) > 0 then
strToRemove = Mid(strToRemove, 1, Len(strToRemove) - 1)
'strToRemove = Left(strToRemove, Len(strToRemove) -1)
ob4.Range(strToRemove).delete
End If
ob4.AutoFilterMode = False
objExcel1.ScreenUpdating = True
objExcel1.Calculation = -4105 'xlCalculationAutomatic
TotalRows=objExcel1.Application.WorksheetFunction.CountA(ob4.Columns(1))
MsgBox(TotalRows)
'ReDim ArrParent(TotalRows - 2)
ArrParent=ob4.Range("A2:A" & TotalRows).value2
'MsgBox(ArrParent(1,0))
'Call to the subroutine
ParentPIDNumber ArrParent,ob3,ob2,ob4
End Sub
谢谢,