Search button

cannonmkt

New Member
Joined
Apr 12, 2018
Messages
7
I have excel 2010 and I have a search button for my spreadsheet where I can search by name or part number. I works and highlites the found data green, that works perfect, HOWEVER, for some reason it moves the mouse to the first cell on next line on spreadsheet instead that line. I need the mouse to be on the column b on same line the found data is on. I entered code below
Code>
Private Sub CommandButton6_Click()
Dim SearchThis As String, Found As Range
Me.Unprotect Password:="123"
SearchThis = InputBox("Type Number or name.", "Property Search")
SearchThis = SearchThis & "*"
Set Found = Columns("c:k").Find(What:=SearchThis, LookIn:=xlFormulas, LookAt:=xlPart)
If Not Found Is Nothing Then
With Found
.Select
.Interior.ColorIndex = 4
End With
End If
Me.Protect Password:="123"
End Sub
Code >

thanks in advance for any help you may provide
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
You're searching in columns C:K and then telling it to Select the found range.

Maybe try this:

Code:
With Found
    .Offset(0,-1).Select
    .Interior.ColorIndex = 4
End With

Or

Range("B" & Found.Row).Select

not sure about that one...and of course if it find what you want in column K, then the first idea will only move over to column J.

Also maybe .End(XlToLeft).offset(0,1).Select

Again, not sure about that one either...just some ideas
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,915
Messages
6,122,212
Members
449,074
Latest member
cancansova

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