Error R/T 1004

jim may

Well-known Member
Joined
Jul 4, 2004
Messages
7,486
I'm getting R/T Error 1004 on RED Line below;
My Range(C2:C5) are 4 strings (AA, BB, CC, DD)
My target cell - while a formula cell - returns a string - such as BB
Ant assistance appreciated.. Jim


Rich (BB code):
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Address <> "$E$1" Then Exit Sub
Dim r As Long, v As String
Cancel = True
Set Rng = Range("C2:C5")
Worksheets("Sheet2").Activate
r = Application.WorksheetFunction.Match(Target.Value, Rng, 0)
Cells(r, 3).Select
End Sub
 
Worksheets("Sheet2").Activate
Set Rng = Range("C2:C5"),,,, "defined on Sheet2!!

Thanks again for all your assistance. Jim

When the code is in a worksheet's code module, unqualified ranges refer to the worksheet of the module and not the ActiveSheet. That's why I used the With Sheet2 to qualify the search range.


Did you try the hyperlink formula in post #7 ?
 
Upvote 0

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
"unqualified ranges refer to the worksheet of the module and not the ActiveSheet" -- Thanks for this type "hidden" fact..

Yes, the hyperlink formula was SPOT-ON!! Why start out the link with the "#" ? -- No such examples are furnished in the Hyperlink Function Help Files. Jim
 
Upvote 0

Forum statistics

Threads
1,216,129
Messages
6,129,055
Members
449,484
Latest member
khairianr

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