Forum Discussion
Garth_B
Jan 25, 2021Copper Contributor
Using a reference cell for Find function
I have a large spreadsheet where non-experienced Excel people need to review and add data At the top, I want to enable an easy way for them to find the relevant section to review or add basic data ...
- Jan 25, 2021
Here is a macro that you can assign to a command button (from the Form Controls section of the Insert dropdown on the Developer tab of the ribbon).
Sub FindIt() Dim rngFind As Range If Range("B1").Value = "" Then Range("B1").Select MsgBox "Please enter a search term, then try again.", vbExclamation Else Set rngFind = Cells.Find(What:=Range("B1").Value, After:=Range("B1"), _ LookAt:=xlPart, MatchCase:=False) If rngFind.Address = "$B$1" Then MsgBox "Text not found :-(", vbExclamation Else Application.Goto rngFind, True End If End If End Sub
HansVogelaar
Jan 25, 2021MVP
Here is a macro that you can assign to a command button (from the Form Controls section of the Insert dropdown on the Developer tab of the ribbon).
Sub FindIt()
Dim rngFind As Range
If Range("B1").Value = "" Then
Range("B1").Select
MsgBox "Please enter a search term, then try again.", vbExclamation
Else
Set rngFind = Cells.Find(What:=Range("B1").Value, After:=Range("B1"), _
LookAt:=xlPart, MatchCase:=False)
If rngFind.Address = "$B$1" Then
MsgBox "Text not found :-(", vbExclamation
Else
Application.Goto rngFind, True
End If
End If
End Sub
- Garth_BJan 25, 2021Copper Contributor
Thanks, Hans
I blundered my way through inserting VBA code and it works beautifully
Cheers Garth