Vous êtes sur la page 1sur 4

Help with comment VBA code.

http://www.excelforum.com/excel-programming-vba-macros/680566-he...

My Profile

Settings

Log Out

Forum

What's New?

Members List

Calendar

Forum Rules

Winner Board
Advanced Search Quick Links

New Posts My Posts Private Messages User CP FAQ Calendar Community Unanswered Threads

Forum Actions

Forum

Microsoft Office Application Help - Excel Help forum Help with comment VBA code.

Excel Programming / VBA / Macros

partho143, You are member of Excel Help Forum for 989 day(s) now but haven't posted anything yet. How about introducing yourself to the rest of the users? Click on this message bar if you wish to make an introduction thread now. If you wish to post a question, please choose the relevant sub-forum.

Results 1 to 3 of 3

Thread: Help with comment VBA code.


Thread Tools Search Thread Rate This Thread Display

04-21-2009, 05:45 PM

#1

Marco-Kun
Valued Forum Contributor

Help with comment VBA code.


I use this VBA code for my comments:

Join Date: Location: MS-Off Ver: Posts:

04-15-2009 Holland Dutch:2007 242

Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'www.contextures.com/xlcomments03.html Dim rng As Range Dim cTop As Long Dim cWidth As Long Dim cmt As Comment Dim sh As Shape ''' Application.DisplayCommentIndicator _ = xlCommentIndicatorOnly If Not m_cmtPrevious Is Nothing Then m_cmtPrevious.Visible = False End If Set rng = ActiveWindow.VisibleRange cTop = rng.Top + rng.Height / 2 cWidth = rng.Left + rng.Width / 2 If ActiveCell.Comment Is Nothing Then 'do nothing Set m_cmtPrevious = Nothing Else Set cmt = ActiveCell.Comment Set sh = cmt.Shape sh.Top = ActiveCell.Offset(1).Top sh.Left = ActiveCell.Offset(1).Left cmt.Visible = True Set m_cmtPrevious = cmt End If

With this current code, the comments show 1 cell below

1 of 4

12/02/2013 2:52 PM

Help with comment VBA code.

http://www.excelforum.com/excel-programming-vba-macros/680566-he...

the selected cell and is aligned to the left. What do I have to adjust to make it align to the right 1 cell below the selected cell.

sh.Top = ActiveCell.Offset(1).Top sh.Left = ActiveCell.Offset(1).Left

Last edited by Marco-Kun; 04-21-2009 at 06:07 PM.


Reply Reply With Quote

04-21-2009, 05:58 PM

#2

shg
Forum Guru

Re: Help with comment VBA code.

Join Date: Location: Texas MS-Off Ver: Posts:

06-21-2007 The Great State of 2003, 2007, 2010 27,622

With ActiveCell.Offset(1) sh.Top = .Top sh.Left = .Left + .Width - sh.Width End With

Microsoft MVP - Excel Entia non sunt multiplicanda sine necessitate

Reply

Reply With Quote

04-21-2009, 06:05 PM

#3

Marco-Kun
Valued Forum Contributor

Re: Help with comment VBA code.


Thank you very much I put it in like this:

Join Date: Location: MS-Off Ver: Posts:

04-15-2009 Holland Dutch:2007 242

Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'www.contextures.com/xlcomments03.html Dim rng As Range Dim cTop As Long Dim cWidth As Long Dim cmt As Comment Dim sh As Shape ''' Application.DisplayCommentIndicator _ = xlCommentIndicatorOnly If Not m_cmtPrevious Is Nothing Then m_cmtPrevious.Visible = False End If

2 of 4

12/02/2013 2:52 PM

Help with comment VBA code.

http://www.excelforum.com/excel-programming-vba-macros/680566-he...

Set rng = ActiveWindow.VisibleRange cTop = rng.Top + rng.Height / 2 cWidth = rng.Left + rng.Width / 2 If ActiveCell.Comment Is Nothing Then 'do nothing Set m_cmtPrevious = Nothing Else Set cmt = ActiveCell.Comment Set sh = cmt.Shape sh.Top = ActiveCell.Offset(1).Top sh.Left = ActiveCell.Offset(1).Left cmt.Visible = True With ActiveCell.Offset(1) sh.Top = .Top sh.Left = .Left + .Width - sh.Width End With Set m_cmtPrevious = cmt End If

Reply

Reply With Quote

Quick Navigation Quick Reply

Excel Programming / VBA / Macros

Top

Post Quick Reply

Go Advanced

Cancel

Previous Thread | Next Thread

3 of 4

12/02/2013 2:52 PM

Help with comment VBA code.

http://www.excelforum.com/excel-programming-vba-macros/680566-he...

All times are GMT +3. The time now is 02:50 PM. Powered by vBulletin Version 4.1.8 Copyright 2012 vBulletin Solutions, Inc. All rights reserved.

Search Engine Friendly URLs by vBSEO 3.2.0

4 of 4

12/02/2013 2:52 PM

Vous aimerez peut-être aussi