Forum Discussion

JonHowarth's avatar
JonHowarth
Copper Contributor
Oct 07, 2022
Solved

Create button to jump to a cell

I have a sheet that tracks purchase order numbers in a table. I'd like to add a search function at the top of the spreadsheet, where you enter the PO number in a cell then press a search button and i...
  • OliverScheurich's avatar
    Oct 07, 2022

    JonHowarth 

    In the attached file you can enter the PO number in cell B1 and click the button in cell C1 to activate the cell with the PO number from B1. The macro currently searches for PO numbers in range A4:A1000 which can be adapted.

    Sub activate_po_number()
    
    Dim i As Long
    
    On Error GoTo errormessage
    
    If Not IsError(i = WorksheetFunction.Match(Range("B1").Value, Range("A4:A1000"), 0)) Then
    
    i = WorksheetFunction.Match(Range("B1").Value, Range("A4:A1000"), 0)
    
    Cells(i + 3, 1).activate
    
    Else
    
    errormessage:
    MsgBox ("PO number not found")
    
    End If
    
    End Sub

Resources