VBA Find Method Deselects Charts

JeffK627

Active Member
Joined
Jun 22, 2005
Messages
313
I'm using the following code in conjunction with an embedded chart to find the row where a specified value is located and use that value in a custom tooltip. The problem is that when this runs it deselects the chart and goes back to the last selected cell, and you have to click on the chart again to continue, which I don't want. Does anyone know a way to do this without using Find, or how to prevent Find from deselecting the chart? I'm working in Excel 2010.

Code:
Function FindTheRow(Rng As Range, sToFind As String) As Long
    FindTheRow = Rng.Cells.Find(What:=sToFind, _
                                After:=Rng.Cells(1), _
                                lookat:=xlPart, _
                                LookIn:=xlFormulas, _
                                SearchOrder:=xlByRows, _
                                SearchDirection:=xlPrevious, _
                                MatchCase:=False).Row
End Function
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Hi

I tried and it did not deselect the chart.

Also I did not understand the "you have to click on the chart again to continue".
You don't usually select objects in vba.
 
Upvote 0
I'm using the mouse move event of the chart to display a custom tooltip when the mouse is over a data point. It only works if the chart is selected. Note that this is a chart embedded in a worksheet, not a chart sheet. I was able to get around it, the solution is too long to post here though. Thanks.
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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