Announcement

Collapse
No announcement yet.

Show Address Of Double Click Of Cell

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Show Address Of Double Click Of Cell

    Can code detect a click or d-click in a cell in Excel and act on that somehow, without the normal edit-cell event?

    Thanks - Kirk

  • #2
    Re: Detect click event in cell

    Right click on the sheet name tab, choose View Code and sue the code below
    Code:
    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
          Cancel = True
          MsgBox Target.Address
        End If
    End Sub

    Comment


    • #3
      Re: Detect click event in cell

      I modified the above code to this. I need effect of: Target = Range("C5:C13") so the corresponding value in Col C will be put in Col D. So when a cell in this range is double clicked the corresponding Cost from C will be put in the clicked cell. So I need to know the cell address I clicked so I can get the Cost from Col C.

      Thank you,

      Code:
      Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
          If Not Intersect(Target, Range("D5:D13")) Is Nothing Then
            Target = Range("C5")
            Debug.Print Target
          End If
      End Sub
      Procedure Cost 7101 7102 7103
      B C D E F
      DR Visit - Include eCRF & source docs for all 202 $ 202.00
      Surgical Intervention 105
      Catheter Reintervention 105
      Additional Implant Catheter 70
      Additional Implant Device Notification 70
      UnPLanned Follow UP 167 $ 167.00
      UnPLanned Echo 132

      Comment


      • #4
        Re: Show Address Of Double Click Of Cell

        I figured it out see the code: Target.row give the row or target.address gives the cell address

        Code:
        Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
            If Not Intersect(Target, Range("D5:Q13")) Is Nothing Then
              Target = Range("C" & Target.Row)
              Debug.Print Target, Target.Address, Target.Row
            End If
        End Sub

        Comment

        Working...
        X