comment or input message

A

Alex

I need to show a comment or data validation input message when a user clicks
in a cell. Comments won't work because we don't want the indicator to show.
Data validation won't work because it won't allow me to publish a List (Excel
2003) to a SharePoint server when data validation is present. So, I'm using
the below code. However, I don't want an actual message box to appear that a
user must click OK to close. Is there a way, in code, to show a cell comment
momentarily when a cell is selected? Thanks.

If Not Intersect(Target, Range("D2:D25")) Is Nothing Then
MsgBox ("Please enter name.")
End If
 
G

Gary''s Student

Very easy:

First enter these two sub to create and destroy a message in a simple textbox:

Sub create_message()
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 263.25, 61.5, 134.25,
61.5). _
Select
Selection.Characters.Text = "Hello world"
With Selection.Characters(Start:=1, Length:=11).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 10
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
End Sub


Sub destroy_message()
On Error GoTo exxit
ActiveSheet.Shapes(1).Select
Selection.Cut
exxit:
End Sub


Then put this event code in the worksheet code area:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'
' gsnuxx
'
Set t = Target
Set b9 = Range("B9")
If Intersect(t, b9) Is Nothing Then
Call destroy_message
Exit Sub
Else
Call create_message
b9.Select
End If
End Sub
 

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