Msgbox when a cell with a specific text entry is selected.

A

andreas

Dear Experts:

I would like to have a macro code which will bring up a message box
when the cell containing the word "REPORT" is either ...

- activated/selected
- or about to be deleted (the user selects the entire column/row for
deletion or the cell in question (and possible adjacent cells) to
clear them).

The msgbox is to say: "Deleting the text entry "REPORT" results
in ...."

Help is much appreciated. Thank you very much in advance.

Regards, Andreas
 
R

Rick Rothstein

Right click the tab at the bottom of the worksheet you want this functionality on, select View Code from the popup menu that appears, then copy/paste the following into the code window that appeared...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Target.Find("Report", LookIn:=xlValues, _
MatchCase:=False) Is Nothing Then
MsgBox "Deleting the text entry ""REPORT"" results in ...."
End If
End Sub

Now fix the message in the MsgBox statement to say what you want. That's it... go back to your worksheet and try to select a cell with only the word "Report" in it (in any letter casing) and the MessageBox should appear.
 
A

andreas

Right click the tab at the bottom of the worksheet you want this functionality on, select View Code from the popup menu that appears, then copy/paste the following into the code window that appeared...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
  If Not Target.Find("Report", LookIn:=xlValues, _
              MatchCase:=False) Is Nothing Then
    MsgBox "Deleting the text entry ""REPORT"" results in ...."
  End If
End Sub

Now fix the message in the MsgBox statement to say what you want. That's it... go back to your worksheet and try to select a cell with only the word"Report" in it (in any letter casing) and the MessageBox should appear.

--
Rick (MVP - Excel)










- Zitierten Text anzeigen -

Hi Rick,

exactly what I wanted. Thank you very much for your terrific help.
Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top