I have an excel sheet where a column has a list validation.
When a particular entry from the list is selected, i need a message box to be popped up.
I could have used the following code if there was only 1 cell, but in my case i have many cells in a column
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim rng As Range
Set rng = Range("A1")
If Not Intersect(Target, rng) Is Nothing Then
If rng = "hi" Then
MsgBox "Cell " & _
rng.Address & " = hi"
End If
End If
Set rng = Nothing
End Sub
Please help
examine the value of the Target.Column property ....
Suppose you want to examine column D (numeric value 4), you do
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 4 ' examine column D
' code to validate Target
If Target = "xxx" Then MsgBox "You chose xxx from the list"
End If
End Sub
Good luck MikeD
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.