Получение ошибки несоответствия типов в приведенном ниже коде. Намерение состоит в том, чтобы вернуть логическое значение в ячейку, которая сравнивает результаты двух выходных данных из двух разных диапазонов. Один диапазон - это просто функция range (), другой - результат, найденный в INDEX MATCH. Функция MATCH выдает ошибку, но я не могу понять, почему.
Есть 2 варианта, которые я попробовал ниже.
dim i as long, j as long
Dim index As Variant
Dim compare As Variant
Dim bool As Boolean
i = 11
Do While i < RAGlastRow + 1
j = 41
Do While j < 44
RAGspreadsheet.Cells(i, j) = Application.IsError(Application.Match(RAGspreadsheet.Range("C" & i).Value, HistoryWS.Range("C11", "C" & lastRow), 0))
j = j + 1
index = Application.index(HistoryWS.Range(Cells(11, 7).Address, Cells(lastRow, 7).Address), Application.Match(RAGspreadsheet.Range("C" & i).Value, HistoryWS.Range("C11", "C" & lastRow), 0))
compare = RAGspreadsheet.Range("H" & i)
bool = index <> compare
RAGspreadsheet.Cells(i, j) = bool
j = j + 1
RAGspreadsheet.Cells(i, j) = RAGspreadsheet.Range("I" & i) <> Application.index(HistoryWS.Range(Cells(11, 8).Address, Cells(lastRow, 8).Address), Application.Match(RAGspreadsheet.Range("C" & i).Value, HistoryWS.Range("C11", "C" & lastRow), 0))
j = j + 1
Loop
i = i + 1
Loop
или
dim i as long, j as long
i = 11
Do While i < RAGlastRow + 1
j = 41
Do While j < 44
RAGspreadsheet.Cells(i, j) = Application.IsError(Application.Match(RAGspreadsheet.Range("C" & i).Value, HistoryWS.Range("C11", "C" & lastRow), 0))
j = j + 1
RAGspreadsheet.Cells(i, j) = RAGspreadsheet.Range("H" & i) <> Application.index(HistoryWS.Range(Cells(11, 7).Address, Cells(lastRow, 7).Address), Application.Match(RAGspreadsheet.Range("C" & i).Value, HistoryWS.Range("C11", "C" & lastRow), 0))
j = j + 1
RAGspreadsheet.Cells(i, j) = RAGspreadsheet.Range("I" & i) <> Application.index(HistoryWS.Range(Cells(11, 8).Address, Cells(lastRow, 8).Address), Application.Match(RAGspreadsheet.Range("C" & i).Value, HistoryWS.Range("C11", "C" & lastRow), 0))
j = j + 1
Loop
i = i + 1
Loop
Это часть MATCH функции INDEX MATCH, которая, кажется, выдает ошибку.