Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to see if Comment Exists


Hi,


I have 2 queries which are currently wrecking my head.

Do you know what the code is to see if a comment exists. If it exists
will amend the text and if it dosen't exist then I will enter a commen
but I dont know how to see if there is alreay one active on the cell.
I thought it would be something like
If Cells(row_index, 2).Comment = True Then

but that is not it. Any ideas.

Also, when I run a macro that has popped upa number of forms , whe
they finish they dont seemto give the contrlol back to the exce
screen. Excel is still on the screen but the blue bar at the top i
slightly out of focus and you have to click on it to bring it back t
vlue. Then you can edit the cells again.

Is there a command to send the screen back so excel will be active ?

Regards
Bria

--
wardide
-----------------------------------------------------------------------
wardides's Profile: http://www.excelforum.com/member.php...fo&userid=1502
View this thread: http://www.excelforum.com/showthread.php?threadid=48873

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code to see if Comment Exists

for the second, possibly ActiveCell.Activate

Dim cmt as Comment
On Error Resume Next
set cmt = ActiveSheet.Range("B9").Comment
On Error goto 0
if not cmt is nothing then
' append text
Else
' add a comment
End if

--
Regards,
Tom Ogilvy


"wardides" wrote in
message ...

Hi,


I have 2 queries which are currently wrecking my head.

Do you know what the code is to see if a comment exists. If it exists I
will amend the text and if it dosen't exist then I will enter a comment
but I dont know how to see if there is alreay one active on the cell.
I thought it would be something like
If Cells(row_index, 2).Comment = True Then

but that is not it. Any ideas.

Also, when I run a macro that has popped upa number of forms , when
they finish they dont seemto give the contrlol back to the excel
screen. Excel is still on the screen but the blue bar at the top is
slightly out of focus and you have to click on it to bring it back to
vlue. Then you can edit the cells again.

Is there a command to send the screen back so excel will be active ?

Regards
Brian


--
wardides
------------------------------------------------------------------------
wardides's Profile:

http://www.excelforum.com/member.php...o&userid=15022
View this thread: http://www.excelforum.com/showthread...hreadid=488734



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Code to see if Comment Exists

Re. comments, I've always error trapped to check whether they exist. For
your needs I would do something like:


Dim myComm as comment
Dim c as range

set c = Activesheet.Cells(1, 1)

On Error Resume Next
Set myComm = c.Comment
On Error GoTo 0
If myComm Is Nothing Then
set myComm = c.Comments.add "My text"
Else
myComm.Text "My text"
End If
set c= nothing
set mycomm = nothing


wardides wrote:
Hi,


I have 2 queries which are currently wrecking my head.

Do you know what the code is to see if a comment exists. If it exists I
will amend the text and if it dosen't exist then I will enter a comment
but I dont know how to see if there is alreay one active on the cell.
I thought it would be something like
If Cells(row_index, 2).Comment = True Then

but that is not it. Any ideas.

Also, when I run a macro that has popped upa number of forms , when
they finish they dont seemto give the contrlol back to the excel
screen. Excel is still on the screen but the blue bar at the top is
slightly out of focus and you have to click on it to bring it back to
vlue. Then you can edit the cells again.

Is there a command to send the screen back so excel will be active ?

Regards
Brian


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to see if Comment Exists


Thanks Tony.


--
wardides
------------------------------------------------------------------------
wardides's Profile: http://www.excelforum.com/member.php...o&userid=15022
View this thread: http://www.excelforum.com/showthread...hreadid=488734

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to see if Comment Exists


Thats cleared it up thanks Lads.


--
wardides
------------------------------------------------------------------------
wardides's Profile: http://www.excelforum.com/member.php...o&userid=15022
View this thread: http://www.excelforum.com/showthread...hreadid=488734



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Code to see if Comment Exists

Just some more options:

Sub Demo()
With ActiveCell
If .Comment Is Nothing Then
.AddComment "First Line" & vbLf
Else
.Comment.Text .Comment.Text & "More Lines" & vbLf
End If
.Comment.Shape.TextFrame.AutoSize = True
End With
End Sub

HTH :)
--
Dana DeLouis
Win XP & Office 2003


"wardides" wrote in
message ...

Thats cleared it up thanks Lads.


--
wardides
------------------------------------------------------------------------
wardides's Profile:
http://www.excelforum.com/member.php...o&userid=15022
View this thread: http://www.excelforum.com/showthread...hreadid=488734



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Code to see if Comment Exists

Neater! Why didn't I think of that....

Dana DeLouis wrote:
Just some more options:

Sub Demo()
With ActiveCell
If .Comment Is Nothing Then
.AddComment "First Line" & vbLf
Else
.Comment.Text .Comment.Text & "More Lines" & vbLf
End If
.Comment.Shape.TextFrame.AutoSize = True
End With
End Sub

HTH :)

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to check if a custom chart exists shoba[_3_] Excel Programming 0 August 4th 05 02:12 PM
Worksheets Exists Code... KimberlyC Excel Programming 3 July 7th 05 09:19 PM
Code to delete all comment boxes Shawn Excel Discussion (Misc queries) 1 June 2nd 05 03:21 PM
VB Code to size the comment box SUNIL PATEL Excel Programming 1 July 1st 04 09:26 PM
Help with code that checks if a sheet exists wachen Excel Programming 2 February 10th 04 02:39 AM


All times are GMT +1. The time now is 10:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"