Intersect command fails with different sheet ranges

darthslayer

New Member
Joined
Apr 10, 2015
Messages
1
I'm trying to create an self updating drop down list. To achive this I found a code and adapted it to my workbook. Code works if it's in the sheet named "default" but when I try to redirect it to another sheet, it stucks in the code below, with this error (method 'intersect' object' _global failed"

Code:
If Intersect(Target, Worksheets("default").Range("c" & count_cells + 1)) Is Nothing Then



Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Application.ScreenUpdating = False
    Dim count_cells As Integer
    Dim new_value As String
    Dim old_value As String
    For count_cells = 1 To Worksheets("default").Range("c2:c400").CurrentRegion.Rows.Count - 1
        If Intersect(Target, Worksheets("default").Range("c" & count_cells + 1)) Is Nothing Then
        Else
            Application.EnableEvents = False
            new_value = Target.Value
            Application.Undo
            old_value = Target.Value
            Target.Value = new_value
            Range("AS:AS").Select
            Selection.Replace What:=old_value, Replacement:=new_value, LookAt:=xlPart, _
            SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
            ReplaceFormat:=False
            Target.Select
        End If
    Next count_cells
    Application.EnableEvents = True
    Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
It's not possible for a range on one sheet to intersect (be within) a range on another sheet. What exactly are you trying to do?

BTW, if you're going to cross post on other forums, which is OK, please provide links to those posts so that we don't duplicate effort that may already have been put in elsewhere.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,403
Messages
6,124,714
Members
449,182
Latest member
mrlanc20

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