Results 1 to 3 of 3

Intersection - Multiple ranges SUDDENLY not supported

Threaded View

Geronim0 Intersection - Multiple... 04-22-2011, 07:27 AM
Marcol Re: Intersection - Multiple... 04-22-2011, 08:04 AM
Geronim0 Re: Intersection - Multiple... 04-22-2011, 08:16 AM
  1. #1
    Registered User
    Join Date
    04-22-2011
    Location
    Holland
    MS-Off Ver
    Excel 2002
    Posts
    3

    Exclamation Intersection - Multiple ranges SUDDENLY not supported

    Hello all,

    As a starting user of VBA in Excel I have frequently used this forum for solutions to my vba problems (many thanks for that!). This time I couldn't find an answer to my problem, so I decided to register and ask for myself.

    I wrote a sub that is fired by the Worksheet_SelectionChange event. I put it in the code page for the Worksheet ("FR") itself. Cut to the bone it looks like this:


    Private Sub Worksheet_SelectionChange (ByVal Target As Range)
     If Not Intersect (Range("C9:R40, C47:R78"), Target) Is Nothing Then
    
     (irrelevant code for this problem)
    
    End if
    
    End Sub
    This worked perfect, until yesterday. Now I get the error 1004 - method range of object_worksheet has failed (translation of the error is mine, since I have a Dutch Office version).

    I changed the code to:

    Private Sub Worksheet_SelectionChange (ByVal Target As Range)
     If Not Intersect (Sheets("FR").Range("C9:R40, C47:R78"), Target) Is Nothing Then
    
     (irrelevant code for this problem)
    
    End if
    
    End Sub

    It still results in an error: 1004 - by application or object defined error

    Then I found out that the resulting problem is in the fact that I defined multiple ranges.

    So when the code is changed to the following, it works:

    Private Sub Worksheet_SelectionChange (ByVal Target As Range)
     If Not Intersect (Sheets("FR").Range("C9:R40"), Target) Is Nothing Then
    
     (irrelevant code for this problem)
    
    End if
    
    End Sub
    So it works for a single range but I need to refer to multiple ranges (even more than in the above mentioned example. I already tried to use the names I specified for the ranges in stead of eg C9:R40, but the error remains.

    The question is:

    - How come I get these 2 errors now and not before yesterday?

    - What can I do about it?

    Help is much appreciated!

    Kind regards,

    Geronimo
    Last edited by Geronim0; 04-22-2011 at 08:17 AM. Reason: Problem solved

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1