Consulting

Results 1 to 3 of 3

Thread: multiple target address

  1. #1
    VBAX Tutor
    Joined
    Jul 2010
    Posts
    225
    Location

    multiple target address

    Hi, trying to trigger events is cells in multiple traget addresses are selected.

    I have merged 3 cells together eg b10:b13 are merged but selecting cell is cell b10

    I have 9 of these from B10 to B32. I'm trying to use below code so if I am selecting any of the 9 cells my other events trigger. My below does not trigger not sure why..

    [vba]If Target.Address = ("$B$8:$B$32") Then
    If Range("ac2") = "I'm here" Then
    MsgBox "Unprotecting for Budgetary adjustments
    End If
    End If[/vba]

    This is in the worksheet selection change.

  2. #2
    VBAX Master Aflatoon's Avatar
    Joined
    Sep 2009
    Location
    UK
    Posts
    1,733
    Location
    The address of the cell is not the entire range. Try:
    [vba]If Not Intersect(Target, Range("B8:B32")) Is Nothing Then
    If Range("ac2") = "I'm here" Then
    MsgBox "Unprotecting for Budgetary adjustments
    End If
    End If [/vba]
    Be as you wish to seem

  3. #3
    Site Admin VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,001
    Location
    You do it using targe.cells.count like this[VBA]If Target.Cells.Count > 1 Then
    MsgBox Target.Address
    Else
    MsgBox "Not merged " & Target.Address
    End If[/VBA]
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

Posting Permissions

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