Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Time Error '91'
Hello,
The following code causes Run Time Error '91' when I insert it into worksheets. The code allows comments to be shown when cell is active. Can anyone help? Private Sub Worksheet_SelectionChange(ByVal Target As Range) Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is Nothing) End Sub Thanks in advance for any help, Paul |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Time Error '91'
On 17 Jan., 17:47, Paul3rd wrote:
Hello, The following code causes Run Time Error '91' when I insert it into worksheets. The code allows comments to be shown when cell is active. Can anyone help? Private Sub Worksheet_SelectionChange(ByVal Target As Range) * *Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is Nothing) End Sub Thanks in advance for any help, Paul Hi Paul The code is fine. Check if you have a comment in cell B4! Regards, Per |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Time Error '91'
Thanks for your quick reply.
You are correct!! I didn't have a comment in the cell. Is there a way to modify the code so no error is triggered if the cell is blank? Thanks again, Paul "Per Jessen" wrote: On 17 Jan., 17:47, Paul3rd wrote: Hello, The following code causes Run Time Error '91' when I insert it into worksheets. The code allows comments to be shown when cell is active. Can anyone help? Private Sub Worksheet_SelectionChange(ByVal Target As Range) Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is Nothing) End Sub Thanks in advance for any help, Paul Hi Paul The code is fine. Check if you have a comment in cell B4! Regards, Per |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Time Error '91'
And you can check for a comment in B4 in code with:
Option Explicit Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Me.Range("B4").Comment Is Nothing Then 'don't try to use .visible Else Me.Range("B4").Comment.Visible _ = Not (Intersect(Target, Range("B4")) Is Nothing) End If End Sub Paul3rd wrote: Hello, The following code causes Run Time Error '91' when I insert it into worksheets. The code allows comments to be shown when cell is active. Can anyone help? Private Sub Worksheet_SelectionChange(ByVal Target As Range) Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is Nothing) End Sub Thanks in advance for any help, Paul -- Dave Peterson |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Time Error '91'
On 17 Jan., 18:49, Paul3rd wrote:
Thanks for your quick reply. You are correct!! I didn't have a comment in the cell. Is there a way to modify the code so no error is triggered if the cell is blank? Thanks again, Paul "Per Jessen" wrote: On 17 Jan., 17:47, Paul3rd wrote: Hello, The following code causes Run Time Error '91' when I insert it into worksheets. The code allows comments to be shown when cell is active. Can anyone help? Private Sub Worksheet_SelectionChange(ByVal Target As Range) * *Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is Nothing) End Sub Thanks in advance for any help, Paul Hi Paul The code is fine. Check if you have a comment in cell B4! Regards, Per- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - Hi Paul Thanks for your reply! This should do the trick Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Range("B4").Comment Is Nothing Then End Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is Nothing) End Sub Regards, Per |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Time Error '91'
Thanks Dave,
That worked perfectly. Paul "Dave Peterson" wrote: And you can check for a comment in B4 in code with: Option Explicit Private Sub Worksheet_SelectionChange(ByVal Target As Range) If Me.Range("B4").Comment Is Nothing Then 'don't try to use .visible Else Me.Range("B4").Comment.Visible _ = Not (Intersect(Target, Range("B4")) Is Nothing) End If End Sub Paul3rd wrote: Hello, The following code causes Run Time Error '91' when I insert it into worksheets. The code allows comments to be shown when cell is active. Can anyone help? Private Sub Worksheet_SelectionChange(ByVal Target As Range) Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is Nothing) End Sub Thanks in advance for any help, Paul -- Dave Peterson |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run Time Error '91'
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Range("B4").Comment Is Nothing Then Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) _ Is Nothing) End If End Sub "Paul3rd" wrote: Thanks for your quick reply. You are correct!! I didn't have a comment in the cell. Is there a way to modify the code so no error is triggered if the cell is blank? Thanks again, Paul "Per Jessen" wrote: On 17 Jan., 17:47, Paul3rd wrote: Hello, The following code causes Run Time Error '91' when I insert it into worksheets. The code allows comments to be shown when cell is active. Can anyone help? Private Sub Worksheet_SelectionChange(ByVal Target As Range) Range("B4").Comment.Visible = Not (Intersect(Target, Range("B4")) Is Nothing) End Sub Thanks in advance for any help, Paul Hi Paul The code is fine. Check if you have a comment in cell B4! Regards, Per |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
run time error 1004 general odbc error excel 2003 vba | Excel Programming | |||
Visual Basic Error Run Time Error, Type Mismatch | Excel Discussion (Misc queries) | |||
Run Time Error 1004: Application or Object Defined Error | Excel Programming | |||
Run Time 1004 Error: Application or Object Difine Error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming |