Hi. I have a command button on an excel sheet that takes the value in the active cell and searches for it on another sheet and then activates the found value.
Where there are multiple values, I'd like to activate the last cell with that value.
Here is my code, for which I'm getting a "compile error: invalid or unqualified reference" for .FindNext
Private Sub CommandButton1_Click() Dim value As String 'Declare a string value = ActiveCell.value 'Get the value of the selected Cell Dim ws As Worksheet 'ws is the worksheet from we are searching the value 'You have to change myWorkSheetName for your worksheet name Set ws = ThisWorkbook.Worksheets("WRITTEN") ws.Activate Dim c As Range 'Declare a cell Set c = ws.Cells.Find(value, LookIn:=xlValues) 'Search the value If Not c Is Nothing Then 'If value found firstAddress = c.Address Set c = .FindNext(c) 'here is where I get the error message If c Is Nothing Then GoTo DoneFinding End If Loop While c.Address <> firstAddress End If DoneFinding: c.Activate 'Activate the cell, select it Else MsgBox "Not found" 'shows a message "Not Found" End If End Sub