Results 1 to 2 of 2

Thread: Excel VBA Target Intersect

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2011
    Posts
    3

    Talking Excel VBA Target Intersect

    Hello All,

    This is my first posting here so I hope to get some great help.

    I have a worksheet called X-Y-G Algorithm. On that worksheet I have 4 Color Codes. They are:

    1 Green
    2 Yellow
    3 Red
    4 Gray

    In columns D1354 I have 7 groups of info that reflect the color Code in cells D1354. On another worksheet titled Cluster View I have some command buttons embedded on the worksheets labeled Button1 - Button 7

    When a user clicks on Button1, I want it to check the values in cells G13:G16 on the R-Y-G Algorithm worksheet for that Group. For Button1 the group range to check against would be D13, D20, D27, D34, D41 and D48.

    When a user Clicks on Button 2 it would check against D14, D21, D28, D35, D42, D49.

    The other buttons would be increment descending.

    When the user clicks the button I want it to display the corresponding code. If there is a 1 for GReen in one of the groups and then a 2 for Red, I want it to display Red for the worst case scenario.

    I found some code on your site while searching:

    Code:
    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim CheckRange As Range
        Dim aCell As Range
        
        Set CheckRange = Intersect(Target, Range("C5:C31"))
        If Not CheckRange Is Nothing Then
            For Each aCell In CheckRange
                If aCell.Value = "Sent" Then
                    MsgBox ("Input Time")
                    Exit For
                End If
            Next
        End If
    End Sub
    from this link: http://www.vbforums.com/showthread.php?t=604798

    I think something similar may be done in my example using Interset and Target.

    Any help will be greatly appreciated!

    Thanks for reading my post!

    Kurt

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Excel VBA Target Intersect

    target is specific to the worksheet change event, your button event has no target
    intersect just finds overlapping cells from 2 ranges, i doubt this helps for what you want to do

    other than that i have no idea what you are trying to do
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width