Oct 07 2022 02:58 AM
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 it takes you to the row for that PO number.
Alternatively, I've used the match function to find the cell reference of the PO number in the search cell. Could a button then be programmed to scroll to that cell reference?
Thanks,
Oct 07 2022 03:30 AM
SolutionIn 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
Oct 07 2022 03:58 AM