ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   comment or input message (https://www.excelbanter.com/excel-programming/407660-comment-input-message.html)

ALEX

comment or input message
 
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


Gary''s Student

comment or input message
 
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


--
Gary''s Student - gsnu200773


"Alex" wrote:

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



All times are GMT +1. The time now is 06:02 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com