ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Positioning a Comment (https://www.excelbanter.com/excel-programming/425065-positioning-comment.html)

kirkm[_8_]

Positioning a Comment
 

Could someone help here please, I'm trying to position
a Comment beside a Form. Using this... which almost
works. r is the Col and row where the comment is.

--
Sub Showc(ByVal r)
Dim rng As Range
Dim cTop
Set rng = ActiveWindow.VisibleRange
cTop = rng.Top + rng.Height / 2
With Worksheets("Sheet1").Range(r)
If Not .Comment Is Nothing Then
With .Comment
With .Shape
.Top = cTop - 215
.Left = Range("M11").Left + 47
End With
.Visible = True
End With
End If
End With
Set rng = Nothing
End Sub
--

The problem is the left position. For some reason it varies.
I haven'e been able to workout a relationship between the
right hand side of the Form - yet, or see if using that is better

..Left in the above is 700 odd; MyForm Left + width is 300ish.

Thanks - Kirk



[email protected]

Positioning a Comment
 
On Mar 4, 8:48*pm, kirkm wrote:
Could someone help here please, I'm trying to position
a Comment beside a Form. *Using this... which almost
works. r is the Col and row where the comment is.

--
Sub Showc(ByVal r)
* * Dim rng As Range
* * Dim cTop
* * Set rng = ActiveWindow.VisibleRange
* * cTop = rng.Top + rng.Height / 2
* * With Worksheets("Sheet1").Range(r)
* * * * If Not .Comment Is Nothing Then
* * * * * * With .Comment
* * * * * * * * With .Shape
* * * * * * * * * * .Top = cTop - 215
* * * * * * * * * * .Left = Range("M11").Left + 47
* * * * * * * * End With
* * * * * * * * .Visible = True
* * * * * * End With
* * * * End If
* * End With
* * Set rng = Nothing
End Sub
--

The problem is the left position. For some reason it varies.
I haven'e been able to workout a relationship between the
right hand side of the Form - yet, or see if using that is better

.Left in the above is 700 odd; *MyForm Left + width is 300ish.

Thanks - Kirk


Have you tried setting the StartupPosition property to "0 - Manual"?
This will allow you to set the Left and Top properties and thereby
control where the UserForm appears when it is shown. This may be of
help to you.

Matt


All times are GMT +1. The time now is 09:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com