Excel VBA - Capitalizing all selected cells in column on double click

前端 未结 2 1443
萌比男神i
萌比男神i 2021-01-19 18:42

I have a very simple VBA script, that capitalizes the selected cell:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Acti         


        
2条回答
  •  天涯浪人
    2021-01-19 18:58

    If DoubleClick is not mandatory, you could use BeforeRightClick. If you want to keep original right click context menu, you could import the module and check for Ctrl/Alt/Shift

    Option Explicit
    
    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
        Dim condition As Boolean
        condition = True ' check Ctrl/Alt/Shift using http://www.cpearson.com/excel/KeyTest.aspx
        If condition Then
            MsgBox "Right Click at " & Target.Address
            Cancel = True
        End If
    End Sub
    

    Another option is to assign a Ctrl+[] in Macro options to a macro instead of an event handling and call the macro to process the Selection object.

提交回复
热议问题