フォルダーを検索して、で終了するすべてのファイルをシートにコピーしました(DAT)。その後VBAを使用してExcelシートの名前にネストされたループ
私はWorksheets("Input").Range("X2")
で発生した日付が、私は で発生したIDにチェックするシートの名前と同じであるかどうかを確認したいWorksheets("Input").Range("c2")
同じIDと正しい日付のシートの1つの名前で一致してください。私は
' for the exact match
Dim mRange As Range
Set mRange = ThisWorkbook.Worksheets("Input").Range("X2")
Set mRange = Range(dicRange, dicRange.End(xlDown))
Dim WS_Count As Integer
Dim I As Integer
' Set WS_Count equal to the number of worksheets in the active
' workbook.
WS_Count = ActiveWorkbook.Worksheets.Count
' Begin the loop.
For Each direc In mRange
For I = 1 To WS_Count
If direc & "K1LTIOS1.DAT" = ActiveWorkbook.Worksheets(I).Nam Then
' Insert your code here.
' The following line shows how to reference a sheet within
' the loop by displaying the worksheet name in a dialog box.
MsgBox ActiveWorkbook.Worksheets(I).Name
(what I want to do actually : copy the whole line from the sheet
ddMMYYK1LOS1.DAT where the ID from Worksheets("Input").Range("c2")` occurs)
End If
Next I
Next
を開始し、この部分で始まるしかし、私はIf direc & "K1LTIOS1.DAT" = ActiveWorkbook.Worksheets(I).Nam Then
にエラーメッセージを取得するには:実行時エラー「438」のを!
1)このエラーの原因は何ですか?
2)おそらくこのようなネストされたループは効率的ではありません。より良い可能性はありますか?
あなたの***はどこにいますか?*** –
このステートメントの 'End if'が不足しています'もしdirec& "K1LTIOS1.DAT" = ActiveWorkbook.Worksheets(I).Nam Then ' –
ああ、申し訳ありません!代わりの方法はどうですか?ネストされたネストされたループの別のメソッドを知っていますか – maniA