У меня возникла проблема с командой FindNext. Этот код, основанный на значении «wash.offset (1, 0)», попытается найти n-й экземпляр строки YAxis2 в листе1. Если «wash.offset (1, 0) = 1», то он найдет первый экземпляр, который отлично работает. Однако проблема возникает, когда «wash.offset (1, 0) = <> 1», тогда я хочу прокрутить экземпляр FindNext для значения «wash.offset (1,0)». Тем не менее, я постоянно получаю ошибку «Невозможно получить свойство FindNext класса Range»Excel VBA Найти следующую команду
Вот код этого
'Find Row
If wash.offset(1, 0) = 1 Then
'wash.offset(1, 1).Select
'Yaxis = ActiveCell.Value
' Set the variable Yaxis to the string value that is located in wash.offset(1, 1)
MsgBox "we are in the wash.offset(1,0) = 1 part of the loop"
Yaxis = wash.offset(1, 1)
'Set wsThis = ThisWorkbook.Sheets("Sheet1")
'wsThis.Range("E13").Value = instno
' This line of code is definitely needed ... lots of troubleshooting discoevered this
ThisWorkbook.Sheets("Sheet1").Select
'
Set Yaxis2 = ActiveWorkbook.Sheets("Sheet1").Cells.Find(What:=Yaxis)
Yaxis2.Select
CellRow = ActiveCell.Row
MsgBox "CellRow = " & CellRow
Else 'elseif wash.offset(1, 0) <> 1 Then
MsgBox "wash.offset(1, 0) = " & wash.offset(1, 0)
' Find first instance of value
Set Yaxis2 = ActiveWorkbook.Sheets("Sheet1").Cells.Find(What:=Yaxis)
cellAddress = ActiveCell.Address
' This loop cycle through the FindNext function the no. times that value in "wash.offset(1, 0)" is equal to
For innerLoop = 1 To wash.offset(1, 0) - 1
ThisWorkbook.Sheets("Sheet1").Select
Set Yaxis2 = ActiveWorkbook.Sheets("Sheet1").Cells.FindNext("cellAddress")
cellAddress = ActiveCell.Address
Next innerLoop
Yaxis2.Select
CellRow = ActiveCell.Row
MsgBox "CellRow = " & CellRow
End If
Вот где я получаю ошибку
Set Yaxis2 = ActiveWorkbook.Sheets ("Лист1"). Cells.FindNext ("cellAddress")