Good morning,

I have a spreadsheet where I need a pop-up box to appear if the value 'x' is entered. However, I did a different pop-up box for each column.


I can get a pop up to appear in one one area, but I don't know how to duplicate for the others (do I copy & past the same code in full, or just bits?). Apologies but this is my first time using VBA so all a bit confusing.

Example below:

If 'x' is entered in Columns A1:B35, text box says '"column one information"
If 'x' is entered in Column C1:D35, text box says "column two information" etc etc etc

Spreadsheet VBA.JPG

This is the code I am currently using

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rg As Range
On Error Resume Next
Set Rg = Application.Intersect(Target, Range("A1:B35"))
If Not Rg Is Nothing Then
If Target.Value = "x" Then
MsgBox "text to show in message box"
Exit Sub
End If
End If
End Sub
Private Sub Worksheet_selectionChange(ByVal Target As Range)
Dim xCell As Range, Rg As Range
On Error Resume Next
Set Rg = Application.Intersect(Target, Range("A1:B35"))
If Not Rg Is Nothing Then
For Each xCell In Rg
If xCell.Value = "x" Then
MsgBox "text to show in message box”
Exit Sub
End If