Advertisement
Mond1c

Untitled

May 8th, 2021
1,017
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.89 KB | None | 0 0
  1. Sub Macro1()
  2.  
  3. rowSize = 1
  4. colSize = 1
  5. i = 6
  6. Do While Not IsEmpty(Cells(5, i))
  7.     i = i + 1
  8.     colSize = colSize + 1
  9. Loop
  10.  
  11. i = 5
  12. Do While Not IsEmpty(Cells(i, 6))
  13.     i = i + 1
  14.     rowSize = rowSize + 1
  15. Loop
  16. rowSize = rowSize - 2
  17. colSize = colSize - 2
  18. Dim MatrixA() As Integer
  19. ReDim MatrixA(rowSize, colSize)
  20.  
  21. For i = 0 To rowSize
  22.     For j = 0 To colSize
  23.         MatrixA(i, j) = Cells(5 + i, 6 + j)
  24.     Next j
  25. Next i
  26.  
  27. Dim ArrB() As Integer
  28.  
  29. Index = 1
  30. For i = 0 To rowSize
  31.     If MatrixA(i, 0) < 10 Then
  32.         ReDim Preserve ArrB(Index)
  33.         ArrB(Index - 1) = MatrixA(i, 0)
  34.         Index = Index + 1
  35.     End If
  36. Next
  37. ReDim Preserve ArrB(Index - 2)
  38.  
  39. ans = ArrB(0)
  40. ansIndex = -1
  41. For i = 0 To UBound(ArrB)
  42.     Cells(5 + i, 4) = ArrB(i)
  43.     If ans < ArrB(i) Then
  44.         ans = ArrB(i)
  45.         ansIndex = i
  46.     End If
  47. Next
  48. Cells(5, 2) = ans & " " & ansIndex
  49. End Sub
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement