code in worksheet not working

jrnyman

Board Regular
Joined
Mar 10, 2002
Messages
105
I have the code below in one of my worksheets. When I first put the code there it worked great. I could double click on a cell, and it took me to the sheet with that cell's name. I tried it today, and i get nothing. What am I missing?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
Sheets(Target.Value).Select
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi,

Remove the On Error statement and report back what happens.

Do you get an error or does nothing happen?

Jay
 
Upvote 0
I took out the error statement and got a run-time error '13' Type mismatch and it highlighted Sheets(Target.Value).Select

The sheet has some merged cells, but otherwise just text.
 
Upvote 0
On 2002-04-11 10:07, jrnyman wrote:
I took out the error statement and got a run-time error '13' Type mismatch and it highlighted Sheets(Target.Value).Select

The sheet has some merged cells, but otherwise just text.

Will the following work?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
Sheets(CStr(Target.Value)).Select
End Sub
 
Upvote 0
No luck. Same error, same line. I really don't understand why this would work yesterday, but not today. What can you do to disable code in worksheets?
 
Upvote 0
On 2002-04-11 10:18, jrnyman wrote:
No luck. Same error, same line. I really don't understand why this would work yesterday, but not today. What can you do to disable code in worksheets?

Place the following in a regular module and then run the sub
--------------------------
Sub test()
Application.EnableEvents = True
End Sub
-------------------------

Then, try the double click again. I am guessing that your enable event setting was set to false.

Jay
 
Upvote 0
Hi,

Sorry.

I cannot duplicate the error. Possibly double click on one of the sheet tabs and copy the text. Paste to the corresponding cell on the main sheet. Other than that, I am at a loss.

Jay
 
Upvote 0
Just an update...

I found the error. The cells I wanted to double-click on were merged cells, and the script could not recognize what the value of the merged cells was. As soon as I unmerged them it worked.
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,114,002
Members
448,543
Latest member
MartinLarkin

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