Hoppa till huvudinnehåll

Hur automatiskt storleksanpassa kommentarrutan så att den passar innehållet i Excel?

När du sätter in kommentarer i celler är storleken på kommentarrutan standard. Om du anger mycket innehåll i det kommer en del av innehållet inte att vara synligt direkt. Är det möjligt att anpassa storleken på kommentarrutan till dess innehåll automatiskt?

Kommentera rutan för automatisk storlek så att den passar innehållet i ett kalkylblad
Kommentera rutan för automatisk storlek för att passa dess innehåll i en rad celler
Komplettera enkelt kommentarrutan automatiskt så att den passar innehållet i det aktiva arket eller hela arket med ett fantastiskt verktyg


Kommentera rutan för automatisk storlek så att den passar innehållet i ett kalkylblad

I Excel kan du dra kommentarrutan till din behovsstorlek manuellt en efter en, men om det finns många kommentarrutor behöver du ändra storlek kommer det här att bli tråkigt och tidskrävande. I det här fallet kan du tillämpa följande VBA-kod.

1. Håll ner ALT + F11 knapparna och det öppnar Microsoft Visual Basic for Applications-fönstret.

2. klick Insert > Modulernaoch klistra in följande makro i Modulfönster.

VBA-kod: Kommentera rutor i storlek automatiskt i ett kalkylblad

Sub FitComments()
'Updateby20140325
Dim xComment As Comment
For Each xComment In Application.ActiveSheet.Comments
    xComment.Shape.TextFrame.AutoSize = True
Next
End Sub

3. Tryck sedan på F5 nyckel för att köra den här koden, och alla kommentarrutor i det aktiva kalkylbladet har ändrats för att passa deras innehåll enligt följande skärmdump:

doc ändra storlek på kommentar1

Tips: Den här koden fungerar bara i det aktuella kalkylbladet och kan inte automatiskt ändra storlek på de nya kommentarrutorna du lägger till.


Ett klick för att snabbt anpassa kommentarrutans storlek till dess innehåll automatiskt i Excel:

Smakämnen Autofit-kommentar nytta av Kutools för Excel kan hjälpa dig att snabbt anpassa storleken på kommentarrutan till dess innehåll automatiskt i ett kalkylblad som nedanstående demo visas. Ladda ner och prova nu! (30 dagars gratis spår)


Kommentera rutan för automatisk storlek för att passa dess innehåll i en rad celler

Om du bara behöver ändra storlek på ett antal cellkommentarrutor kan du använda följande VBA-kod.

1. Håll ner ALT + F11 knapparna och det öppnar Microsoft Visual Basic for Applications-fönstret.

2. klick Insert > Modulernaoch klistra in följande makro i Modulfönster.

VBA-kod: Auto-storlek kommentarrutor i en rad celler

Sub Fitrangecomments()
'Updateby20140325
Dim rng As Range
Dim WorkRng As Range
xTitleId = "KutoolsforExcel"
Set WorkRng = Application.Selection
Set WorkRng = Application.InputBox("Range", xTitleId, WorkRng.Address, Type:=8)
For Each rng In WorkRng
    If Not rng.Comment Is Nothing Then
        rng.Comment.Shape.TextFrame.AutoSize = True
    End If
Next
End Sub

3. Tryck sedan på F5 nyckel för att köra den här koden, och en snabbruta visas för att påminna dig om att välja ett cellområde som du vill ändra storlek på kommentarrutorna, se skärmdump:

doc-resize-comment-box3

4. Och klicka sedan på OK, de valda cellkommentarrutorna har automatiskt anpassats till kommentarinnehållet.

Tips: Den här koden kan inte automatiskt ändra storlek på de nya kommentarrutorna du lägger till.


Kommentera rutan för automatisk storlek för att passa innehållet i det aktiva arket eller hela arket 

Du kan prova Kommentar för automatisk anpassning nytta av Kutools för Excel för att automatiskt ändra storlek på aLl kommentarrutor i aktivt ark eller alla ark i Excel. Gör så här.

Innan du ansöker Kutools för ExcelBer ladda ner och installera det först.

1. Om du vill ändra storlek på kommentarrutor så att de passar innehållet i ett aktivt ark, klicka Kutools > Snarare > Kommentar för automatisk anpassning > Aktivt ark.

Och om du vill ändra storlek på alla kommentarrutor i hela arbetsboken, klicka Kutools > Snarare > Kommentar för automatisk anpassning > Alla lakan. Se skärmdump:

Sedan ändras alla kommentarrutor automatiskt så att de passar deras innehåll. Se skärmdump:

Anmärkningar:

  • 1. Efter att automatiskt ändra storlek på kommentarrutorna kommer kommentarrutan att automatiskt expandera eller krympa med innehållet när du redigerar kommentaren igen.
  • 2. För de nya kommentarerna som du har lagt in måste du aktivera detta AutoFit-kommentarverktyg igen för att ändra storlek på alla nya infogade kommentarrutor.

  Om du vill ha en gratis provperiod (30 dagar) av det här verktyget, klicka för att ladda ner den, och gå sedan till för att tillämpa operationen enligt ovanstående steg.


Anpassa enkelt kommentarrutan automatiskt så att den passar dess innehåll


Relaterade artiklar:

Bästa kontorsproduktivitetsverktyg

🤖 Kutools AI Aide: Revolutionera dataanalys baserat på: Intelligent utförande   |  Generera kod  |  Skapa anpassade formler  |  Analysera data och generera diagram  |  Anropa Kutools funktioner.
Populära funktioner: Hitta, markera eller identifiera dubbletter   |  Ta bort tomma rader   |  Kombinera kolumner eller celler utan att förlora data   |   Rund utan formel ...
Superuppslag: Flera kriterier VLookup    VLookup med flera värden  |   VSök över flera ark   |   Fuzzy Lookup ....
Avancerad rullgardinslista: Skapa snabbt en rullgardinslista   |  Beroende rullgardinslista   |  Flervals-rullgardinslista ....
Kolumnhanterare: Lägg till ett specifikt antal kolumner  |  Flytta kolumner  |  Växla synlighetsstatus för dolda kolumner  |  Jämför intervall och kolumner ...
Utvalda funktioner: Rutnätsfokus   |  Designvy   |   Stor formelbar    Arbetsbok & Bladhanterare   |  Resursbibliotek (Automatisk text)   |  Datumväljare   |  Kombinera arbetsblad   |  Kryptera/Dekryptera celler    Skicka e-postmeddelanden efter lista   |  Superfilter   |   Specialfilter (filtrera fet/kursiv/genomstruken...) ...
Topp 15 verktygssatser12 text verktyg (lägga till text, Ta bort tecken, ...)   |   50+ Diagram Typer (Gantt Chart, ...)   |   40+ Praktiskt Formler (Beräkna ålder baserat på födelsedag, ...)   |   19 Införande verktyg (Infoga QR-kod, Infoga bild från sökväg, ...)   |   12 Konvertering verktyg (Siffror till ord, Valutaväxling, ...)   |   7 Slå ihop och dela verktyg (Avancerade kombinera rader, Dela celler, ...)   |   ... och mer

Uppgradera dina Excel-färdigheter med Kutools för Excel och upplev effektivitet som aldrig förr. Kutools för Excel erbjuder över 300 avancerade funktioner för att öka produktiviteten och spara tid.  Klicka här för att få den funktion du behöver mest...

Beskrivning


Fliken Office ger ett flikgränssnitt till Office och gör ditt arbete mycket enklare

  • Aktivera flikredigering och läsning i Word, Excel, PowerPoint, Publisher, Access, Visio och Project.
  • Öppna och skapa flera dokument i nya flikar i samma fönster, snarare än i nya fönster.
  • Ökar din produktivitet med 50 % och minskar hundratals musklick för dig varje dag!
Comments (19)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi. I've been using an xls spreadsheet for 10+ years. Suddenly, all my note boxes were hugely expanded, showed as a blank note until I edited them. Your solution below worked to resize all of my note boxes to fit contents. But now when I try to resize the note box to add more text, Excel crashes. This is even after I saved as an xlsx file to remove all VB code. Can you help?

Sub FitComments()
'Updateby20140325
Dim xComment As Comment
For Each xComment In Application.ActiveSheet.Comments
xComment.Shape.TextFrame.AutoSize = True
Next
End Sub
This comment was minimized by the moderator on the site
Bom-dia,

Salvou de mais! Após abrir planilha no celular todos os comentários ficaram desajustados no pc.
Tinha mais de 10 mil comentários pra arrumar o tamanho da caixa! Se tivesse pix eu até pagava! Obrigado.
This comment was minimized by the moderator on the site
It doesn't work, the insert module does not show up
This comment was minimized by the moderator on the site
amazing! thank you, the first way works! saved me hours of work!
This comment was minimized by the moderator on the site
I guess Crystal got us off track the question was: Is there a way of making the line from the comment box to the cell darker or fatter? That would be the line surrounding the comment box. TIA DD
This comment was minimized by the moderator on the site
Is there a way of making the line from the comment box to the cell darker or fatter?
This comment was minimized by the moderator on the site
Hi Demondrew,
Sorry can help you for that.
This comment was minimized by the moderator on the site
Thank you so much for sharing this. Really helpful!
This comment was minimized by the moderator on the site
@DENNIE "While the code works it makes the box one line high meaning that large comments disappear off-page somewhere. Could you give the code for fixing the width of each box (to let's say three standard Excel column widths) and auto-adjusting the length of the box to fit the text? Thanks." // Agreed
This comment was minimized by the moderator on the site
Thank you very much. This really saved me from lots of hassles.
This comment was minimized by the moderator on the site
While the code works it makes the box one line high meaning that large comments disappear off-page somewhere. Could you give the code for fixing the width of each box (to let's say three standard Excel column widths) and auto-adjusting the length of the box to fit the text? Thanks.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations