Přidat otázku mezi oblíbenéZasílat nové odpovědi e-mailem vycentrovani a automaticka velikost komentaru v excelu

Mam uz kod na "Show comments in Centre of Active Window" ale potřeboval bych zaroven i to, abych nemusel pokazdy kdyz napisu delsi text do komentare ho pak rucne zvetsovat abych ho viděl. Nemate nejaky kod na obe veci?

Na vycentrovani pouzivam:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'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

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

End Sub

Předmět Autor Datum
Vyzkoušej Private Sub Worksheet_SelectionChange(ByVal Target As Range) 'www.contextures.com/xlcomme…
Siki83 22.03.2017 22:44
Siki83
vysledek: snazi se to sice centrovat, ale kdyz je delsi text tak to pak stejne prekryva, tak ze to n…
dsfefw 23.03.2017 15:08
dsfefw
Samozřejmě se komentář roztahuje jak do šířky, tak do výšky. Pokud naženeš do komentáře text v jedno… poslední
Siki83 23.03.2017 16:00
Siki83

Vyzkoušej

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

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

přidán řádek
sh.TextFrame.AutoSize = True

Zpět do poradny Odpovědět na původní otázku Nahoru