PC Review


Reply
Thread Tools Rate Thread

Code crashes after clearing comments

 
 
L. Howard Kittle
Guest
Posts: n/a
 
      19th Feb 2006
Hello Excel users and experts,

I offered this code to a poster about 4 or 5 posts below this one (Gary
11:35) and now I find that the codes seems to crash after I clear the series
of comments it compiles in column A. Not good!!

Any ideas where I am going wrong?

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False
If Target <> Range("F1") Then Exit Sub
Range("A100").End(xlUp).Offset(1, 0).Select

With Selection
.AddComment
.Comment.Text Text:=Range("E1").Value & ":" _
& Chr(10) & Range("F1").Value
.Comment.Visible = True
.Value = Range("F1").Value
End With

Range("F1").ClearContents
Range("F1").Select
Application.EnableEvents = True
End Sub

Thanks,
Howard


 
Reply With Quote
 
 
 
 
Chip Pearson
Guest
Posts: n/a
 
      20th Feb 2006
The problem may lie in the lines

> Application.EnableEvents = False
> If Target <> Range("F1") Then Exit Sub


Here, you exit the sub without restoring EnableEvents back to
True.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"L. Howard Kittle" <(E-Mail Removed)> wrote in message
news:hs6dnQaigdpLcGXeRVn-(E-Mail Removed)...
> Hello Excel users and experts,
>
> I offered this code to a poster about 4 or 5 posts below this
> one (Gary 11:35) and now I find that the codes seems to crash
> after I clear the series of comments it compiles in column A.
> Not good!!
>
> Any ideas where I am going wrong?
>
> Option Explicit
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> On Error Resume Next
> Application.EnableEvents = False
> If Target <> Range("F1") Then Exit Sub
> Range("A100").End(xlUp).Offset(1, 0).Select
>
> With Selection
> .AddComment
> .Comment.Text Text:=Range("E1").Value & ":" _
> & Chr(10) & Range("F1").Value
> .Comment.Visible = True
> .Value = Range("F1").Value
> End With
>
> Range("F1").ClearContents
> Range("F1").Select
> Application.EnableEvents = True
> End Sub
>
> Thanks,
> Howard
>



 
Reply With Quote
 
L. Howard Kittle
Guest
Posts: n/a
 
      20th Feb 2006
Thanks Chip, I changed...

If Target <> Range("F1") Then Exit sub

To:

If Target <> Range("F1") Then
Application.EnableEvents = True
Exit Sub
End If

WOW, seems to have solved the problem.
Have to admit, I do not understand why the "select rows > delete comments"
event would bust the code. Also I delete cell contents... but whatever???

Thanks a ton Chip, always a pleasure!
Regards,
Howard

New code...

Option Explicit

Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
Application.EnableEvents = False

If Target <> Range("F1") Then
Application.EnableEvents = True
Exit Sub
End If

Range("A100").End(xlUp).Offset(1, 0).Select

With Selection
.AddComment
.Comment.Text Text:=Range("E1").Value & ":" _
& Chr(10) & Range("F1").Value
.Comment.Visible = True
.Value = Range("F1").Value
End With

Range("F1").ClearContents
Range("F1").Select
Application.EnableEvents = True
End Sub



"Chip Pearson" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> The problem may lie in the lines
>
>> Application.EnableEvents = False
>> If Target <> Range("F1") Then Exit Sub

>
> Here, you exit the sub without restoring EnableEvents back to True.
>
>
> --
> Cordially,
> Chip Pearson
> Microsoft MVP - Excel
> Pearson Software Consulting, LLC
> www.cpearson.com
>
>
>
> "L. Howard Kittle" <(E-Mail Removed)> wrote in message
> news:hs6dnQaigdpLcGXeRVn-(E-Mail Removed)...
>> Hello Excel users and experts,
>>
>> I offered this code to a poster about 4 or 5 posts below this one (Gary
>> 11:35) and now I find that the codes seems to crash after I clear the
>> series of comments it compiles in column A. Not good!!
>>
>> Any ideas where I am going wrong?
>>
>> Option Explicit
>>
>> Private Sub Worksheet_Change(ByVal Target As Range)
>> On Error Resume Next
>> Application.EnableEvents = False
>> If Target <> Range("F1") Then Exit Sub
>> Range("A100").End(xlUp).Offset(1, 0).Select
>>
>> With Selection
>> .AddComment
>> .Comment.Text Text:=Range("E1").Value & ":" _
>> & Chr(10) & Range("F1").Value
>> .Comment.Visible = True
>> .Value = Range("F1").Value
>> End With
>>
>> Range("F1").ClearContents
>> Range("F1").Select
>> Application.EnableEvents = True
>> End Sub
>>
>> Thanks,
>> Howard
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007 - Clearing All Comments Jeff Lowenstein Microsoft Excel Misc 1 11th Apr 2009 01:01 AM
Clearing Comments kirkm Microsoft Excel Programming 5 22nd Feb 2009 02:05 PM
Clearing Comments? (PeteCresswell) Microsoft Excel Programming 6 22nd Jan 2007 10:07 AM
Code seems to crash after clearing comments L. Howard Kittle Microsoft Excel Programming 2 20th Feb 2006 06:43 PM
IE6 crashes on clearing AutoComplete the stilt Windows XP Internet Explorer 0 12th Mar 2004 05:34 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:54 PM.