エラーが発生する理由を教えてくださいSubscript out of range- ArrParent
。私が使用したときMsgBox(Lbound(ArrParent))
-それは私に1として与え、私が使用したときMsgBox(Ubound(ArrParent))
-それは私に960として与えています。したがって、以下の行で私はそのようなout of range
エラーを受け取ります。Dic(ArrParent(Count))=Count+2
以下の完全なコードを見つけてください。
コード
Sub ParentPIDNumber(ArrParent,ob3,ob2,ob4)
Dim Dic,DicItems,Dickeys
Dim Count
Set Dic = CreateObject("Scripting.Dictionary")
Count=LBound(ArrParent)
'MsgBox(ArrParent(Count))
Do Until Count > UBound(ArrParent) - 1
Dic(ArrParent(Count))=Count+2 'here Dictionary keys are holding the row numbers as their Items
Count=Count+1
Loop
ParentChildBinding Dic,ob3,ob2,ob4
End Sub
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).Value
'Call to the subroutine
ParentPIDNumber ArrParent,ob3,ob2,ob4
End Sub
ここで私を助けてください!