VBA code in excel to search contents and go to or display corresponding results
Posted on 2007-07-31
I have a table of data in excel.... first column (B) has acronyms in it.
I wish to have a cell above this to act like an input text box and have a search button which then executes a VBA search and either goes to the cell in row B which contains that term or idealy, would retrieve the meaning (text) from the corresponding cell in the next column and display/paste it in cell D4.
I wish to have a msg box appear if nothing is found.
I have drafted the following code yet have no idea how to pick up the contents of the cell based on the cell location (C4): (a button would call the following procedure)
Cells.Find(What:=Range("C4"), After:=ActiveCell, LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False _
'then an IF statement or something - IF found then go to cell or display result in cell D4, else msg box