Search Range.. Always Select Cell Certain Column same row

buzz71023

Active Member
Joined
May 29, 2011
Messages
295
Office Version
  1. 2016
Platform
  1. Windows
I have this code below that searches for whatever is entered in an inputbox. The only columns that will it will search will be columns C and D. After the search is made I want to select the cell in F as the same row as what it finds in C or D.

For instance if the user searches for 101010 and it is found in C11 I would like to select F11. The same goes for if the value is found in D11 I would still like to select whatever is in F11.

Below is what I have so far.

Code:
Dim myITEM As String, myRng As Range, NewLoc As String

'Search for Product Code or Lot Number

myITEM = InputBox("Enter what you would like to search for.", "Search", "Enter Here")

Cells.Find(What:=myITEM, LookIn:=xlValues).Activate

'This is where I need to select whatever is F11
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Try

Code:
Dim myITEM As String, myRng As Range, NewLoc As String
Dim Found As Range

'Search for Product Code or Lot Number

myITEM = InputBox("Enter what you would like to search for.", "Search", "Enter Here")

Set Found = Columns("C:D").Find(What:=myITEM, LookIn:=xlValues, lookat:=xlWhole)

If Found Is Nothing Then
    MsgBox "Not found"
Else
    Range("F" & Found.Row).Select
End If
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top