レポート (Excel ワークシート) を取得し、行を操作し、次の行に移動し、次の行などに移動し、次の最初の 2 つのセルが次のセルになるまで Do Until ループを終了するアプリケーションを作成しようとしています。次のように行が空です (処理する行がこれ以上ないことを示します)。
Imports Excel = Microsoft.Office.Interop.Excel
Dim MSExcel As New Excel.Application
MSExcel.Visible = True
Dim WorkbookA As Excel.Workbook
Dim WorksheetA As Excel.Worksheet
Dim i As Integer = 2 'Skipping header row
Dim Split() As String
Dim SomeStrings() As String = {"StringA", "StringB"} 'etc... an array of strings
WorkbookA = MSExcel.Workbooks.Open(TextBox1.Text)
WorksheetA = WorkbookA.Sheets.Item(1)
Do Until WorksheetA.Cells(i, 1).Value = "" And WorksheetA.Cells(i, 2).Value = ""
'~~If Column A cell does not contain 'valueA' or Column E cell does not contain 'valueB', delete the row
Do Until InStr(WorksheetDisplay.Cells(i, 1).Value, "ValueA") <> 0 And InStr(WorksheetDisplay.Cells(i, 5).Value, "ValueB") <> 0 _
And InStr("somenumbershere", Strings.Left((WorksheetDisplay.Cells(i, 3).Value), 1)) <> 0 'Only keeps entries that begin with a certain number
WorksheetDisplay.Rows(i).Delete() 'Otherwise we delete the row
Loop
For Each Str As String In SomeStrings
If Str = WorksheetDisplay.Cells(i, 3).Value Then
Split = Strings.Split(WorksheetDisplay.Cells(i, 3).Value, " ")
WorksheetDisplay.Cells(i, 3).Value = Split(0) & " some text here"
End If
Next
i = i + 1
Loop
ただし、プログラムの実行が停止することはありません。
理由はありますか?