Code Modification

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

Hey guys

The below code looks in the specified range(D1:CA1) and
trys to match the value of combobox1. Currently if it
finds the value, it says it was found, if not it says it
was not found. Instead of this if the value is found I
want it to select the cell in row 2 of the matching column
it found the value in. For instance lets say the value of
the combobox is "dog". The code is then run and it finds
the value "dog" in column H. If this is the case I want
cell H2 to be selected and thats all. If the value dog
was not found in the range, just show my msgbox.

Dim FndRng As Range
Set FndRng = Workbooks("2004 Renewals New.xls").Sheets
("Renewals WOW 2004").Range("D1:CA1").Find(ComboBox1.Value)
If Not FndRng Is Nothing Then
MsgBox ComboBox1.Value & " was found!"
Else
MsgBox ComboBox1.Value & " was not found. Please check
your data and try again."
End If


Thank you.
 
Todd

FndRng.Parent.Parent.Activate 'activates the workbook
FndRng.Parent.Activate 'activates the worksheet
FndRng.Parent.Cells(2,FndRng.Column).Select 'selects the cell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top