Worksheet Selection Change

  • Hello:

    Im currently writing a pretty simple macro where when I select a particular cell it runs a macro automatically. When I click on the target cell simply nothing happens. I have turned on events using ctrl+G and typing Application.EnableEvents = True. Here is my code and any help is welcome.

    1. Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    2. Dim KeyCell As Range
    3. Set KeyCell = Range("B43")
    4. If Target.Address = KeyCell Then
    5. Call Macro1
    6. End If
    7. End Sub

    In addition, here is the Macro1 I am trying to call:

    1. Sub Macro1()
    2. Range("d35").Select
    3. If ActiveCell<>ActiveCell.Offset(0,1) Then
    4. Range("d35:e35").Select
    5. End if
  • Re: Worksheet Selection Change

    Is it because nothing has changed? your code is Worksheet_SelectionChange, but you have said when you click into a cell... So you need to change the text in the cell, or change the code to click

  • Re: Worksheet Selection Change

    From what I understood SelectionChange fired a macro upon selecting a cell (hopefully in particular the key cell I have set). In addition, I have tried entering data into that cell and that has not worked either.

  • Re: Worksheet Selection Change

    Accounting_Hoyl - please use code tags in future as per forum rules.

    You are comparing a string (address) with a range variable so instead try

    1. If Target.Address = KeyCell.address Then