我正在尝试使用多个条件迭代这个excel文档。
找到名称后,请遍历行以查找其他条件,直至找到包含文字的行。
虽然行是空白的,但只检查另一列是否为整数。如果它是一个整数,请从某列中获取一个值。
当您点击包含文字的行时,请继续检查该名称并继续。完成excel范围后,获取一个新名称。
迭代永远不会进入rangechecker,即使名称匹配时有很多范围。
For i = 0 To physid.Count - 1
Dim physamount As Int64 = 0
range = oxlsheet.UsedRange 'Setting the range to be equal to the length of the excel file
For rcnt = 1 To range.Rows.Count
varray = CType(range.Cells(rcnt, 4), Excel.Range) 'setting varray to the range of the excel workbook
If (IsNumeric(varray.value)) Then
temp = varray.value.ToString
Else
temp = varray.value
End If
If (rcnt > 8) Then
If (IsNumeric(varray.Columns(4).value)) Then
temp2 = varray.Columns(4).value.ToString
Else
temp2 = varray.Columns(4).value
End If
If (temp2 = physid.Item(i)) Then
counter = rcnt
Do While (String.IsNullOrEmpty(temp2) And counter < range.Rows.Count)
rangechecker = oxlsheet.Range("F" & counter).Select()
If Integer.TryParse(rangechecker, 0) Then
If CInt(rangechecker) > 60000 And CInt(rangechecker) < 70000 Then
physamount = physamount + oxlsheet.Range("H" & counter).Select()
Console.WriteLine(physamount)
Console.ReadLine()
End If
End If
counter = counter + 1
Loop
End If
End If
Next
'Write results at the end
Console.WriteLine(physid.Item(i))
Console.WriteLine(physname.Item(i))
Console.WriteLine(physamount)
Console.ReadLine()
Next i