Excel VBA display a message once a specified cell is click.
Popup a message box on Excel when a particular cell is click by the user.
Here's the simple VBA code snippet:
//=======================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Range(xtarget)
//=======================
Click labels below for more VBA tips..
Popup a message box on Excel when a particular cell is click by the user.
Here's the simple VBA code snippet:
//=======================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xtarget
'this message will always display which ever cell is click
on the worksheet
MsgBox
Target.Address & " is selected"
xtarget = Target.Address
'if A1 is click msgbox message below will be displayed
If xtarget = "$A$1" Then
MsgBox "You selected A1, please don't harm the
value"
End If
End Sub
//=======================
The code can be tweak also to display the cell comment on the message box.
//=======================
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim xtarget
xtarget = Target.Address
Dim varxComment As String
Dim xcom As Comment
xtarget = Target.Address
Dim varxComment As String
Dim xcom As Comment
With Range(xtarget)
On Error Resume Next
Set xcom = .Comment
On Error GoTo 0
If xcom Is Nothing Then
MsgBox "No comment", vbExclamation
Else
varxComment = xcom.Text
MsgBox "Cell has comment by - - " + vbCrLf + varxComment, vbInformation, "NOTICE"
End If
Set xcom = .Comment
On Error GoTo 0
If xcom Is Nothing Then
MsgBox "No comment", vbExclamation
Else
varxComment = xcom.Text
MsgBox "Cell has comment by - - " + vbCrLf + varxComment, vbInformation, "NOTICE"
End If
End With
End Sub
End Sub
//=======================
Click labels below for more VBA tips..
Cheers!!! Hope it helps..
Excel Keyboard shortcuts guide
https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
Excel Keyboard shortcuts guide
https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
https://play.google.com/store/apps/details?id=com.myrosaryapp
Comments
Post a Comment