Home |
Search |
Today's Posts |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Paul
Please ignore my previous e-mail as I have managed to get the code to run by deleting some spaces. This is great, but I must ask you a further favour. Can you tell me whether it is possible to run some code that will delete the message that is created by your original code as I do not want the message to remain indefinately on the sheet. Also is it possible to change the colour of the message background and text colour. Sorry for being a pain. Thanks for your help Regards John "Paul B" wrote: John, if you select edit objects when you protect the sheet you will be able to put in comments, or maybe use a macro like this Sub AddComment() 'This code inserts a comment and allows you to enter the multi-lined text 'like using a typewriter. ' Enter one line at a time and it's resized at the end automatically 'By: Andrew Engwirda 'From http://blog.livedoor.jp/andrewe/ July 27,2005 'Code added to unprotect and protect the sheet On Error Resume Next Dim cmtMsg As String, nwLne As String, LneCnt As Long, shCmt As Long Const Password As String = "123" '*********Change Password Here************ If TypeName(Selection) < "Range" Then Exit Sub ActiveSheet.Unprotect Password:=Password AddLine: nwLne = InputBox("Text Line: " & LneCnt + 1 & vbNewLine & vbNewLine & _ "New Text Lines are added automatically." & vbNewLine & _ "Leave blank or push ""Cancel"" to exit.", "Please write your comment") If LneCnt 0 Then cmtMsg = cmtMsg & Chr(10) & nwLne Else cmtMsg = nwLne LneCnt = LneCnt + 1 If nwLne < "" Then GoTo AddLine cmtMsg = Left(cmtMsg, Len(cmtMsg) - 1) Application.ScreenUpdating = False With ActiveCell .ClearComments .AddComment With .Comment .Visible = True .Shape.AutoShapeType = msoShapeRoundedRectangle .Shape.Shadow.Visible = msoFalse .Shape.Select True .Text Text:=cmtMsg If cmtMsg < "" Then .Shape.TextFrame.AutoSize = True shCmt = MsgBox("Do you want the comment to remain visible? ", _ vbYesNo, "Keep comment visible?") If shCmt = vbNo Then .Visible = False End With .Select End With ActiveSheet.Protect Password:=Password Application.ScreenUpdating = True End Sub -- Paul B Always backup your data before trying something new Please post any response to the newsgroups so others can benefit from it Feedback on answers is always appreciated! Using Excel 2002 & 2003 "John Davies" wrote in message ... I have a protected spreadsheet that occasionaly I need to add comments or notes to. However all cells on the sheet are in use. Is it possible to have a command button that if it is clicked will bring up a resizeable box that text can be entered into? If so please advise on the code needed. Thanks in advance for any help. Regards John |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Find text in free-format text field | Excel Discussion (Misc queries) | |||
Automate text import wizard in a protected sheet | Excel Discussion (Misc queries) | |||
How do I make a text box accessible in a protected Excel sheet? | Excel Worksheet Functions | |||
TEXT TO COLUMNS PROTECTED SHEET | Excel Discussion (Misc queries) | |||
Problem pasting a row from a hidden sheet to the first free row on another visible sheet | Excel Programming |