簡體   English   中英

VBA Excel - 如果列中的某個值符合我的條件,則顯示一條消息

[英]VBA Excel - If a certain value in the column matches my criteria then display a message

我想創建一個在我處理 Excel 工作表時在后台繼續運行的宏。

功能:如果整列中的某個單元格 = Now() 則顯示一個消息框。

有人可以分享這個代碼嗎?

把它放在你的工作表模塊中

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
' for a certain column - in this case G
    Dim Arr
        Arr = Split(Target.Address, "$")
        If Arr(1) = "G" Then
            Beep
            MsgBox "You have selected column G..."
        End If

' for a certain row - in this case 2
    If Right(Target.Address, 2) = "$2" Then
        Beep
        MsgBox "You have selected Row 2..."
    End If

' for a certain cell - in this case A3
    If Target.Address = "$A$3" Then
        Beep
        MsgBox "You have selected Cell A3..."
    End If


End Sub

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM