Gå til hovedindhold

Hvordan zoomer eller forstørres valgte celler i Excel? 

Som vi alle ved, har Excel en zoom-funktion, der hjælper os med at øge størrelsen på celleværdien i hele regnearket. Men nogle gange er vi kun nødt til kun at zoome eller forstørre de valgte celler. Er der gode ideer til, at vi kun kan forstørre de valgte celler i et regneark?

Zoom eller forstør den valgte celle med VBA-kode


Zoom eller forstør den valgte celle med VBA-kode

Måske er der på ingen direkte måde for os at forstørre de valgte celler i Excel, men her kan jeg introducere en VBA-kode til at håndtere dette job som en løsning. Gør som følger:

1. Højreklik på arkfanen, som du vil forstørre de valgte celler automatisk, og vælg derefter Vis kode fra genvejsmenuen i det åbnede Microsoft Visual Basic til applikationer vindue, kopier og indsæt følgende kode i det tomme modul:

VBA-kode: Zoom eller forstør de valgte celler:

Private Sub worksheet_selectionchange(ByVal Target As Range)
'Updateby Extendoffice
    Dim xRg As Range
    Dim xCell As Range
    Dim xShape As Variant
    Set xRg = Target.Areas(1)
    For Each xShape In ActiveSheet.Pictures
        If xShape.Name = "zoom_cells" Then
            xShape.Delete
        End If
    Next
    If Application.WorksheetFunction.CountBlank(xRg) = xRg.Count Then Exit Sub
    Application.ScreenUpdating = False
    xRg.CopyPicture appearance:=xlScreen, Format:=xlPicture
    Application.ActiveSheet.Pictures.Paste.Select
    With Selection
        .Name = "zoom_cells"
        With .ShapeRange
            .ScaleWidth 1.5, msoFalse, msoScaleFromTopLeft
            .ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft
            With .Fill
                .ForeColor.SchemeColor = 44
                .Visible = msoTrue
                .Solid
                .Transparency = 0
            End With
        End With
    End With
    xRg.Select
    Application.ScreenUpdating = True
    Set xRg = Nothing
End Sub

2. Gem og luk derefter dette kodevindue, når du vælger eller klikker på nogle dataceller, forstørres cellerne automatisk som et billede, se skærmbillede:

Bemærk: De valgte celler ændres tilbage til originalstørrelse efter valg af andre celler.

Bedste kontorproduktivitetsværktøjer

🤖 Kutools AI Aide: Revolutionér dataanalyse baseret på: Intelligent udførelse   |  Generer kode  |  Opret brugerdefinerede formler  |  Analyser data og generer diagrammer  |  Aktiver Kutools funktioner...
Populære funktioner: Find, fremhæv eller identificer dubletter   |  Slet tomme rækker   |  Kombiner kolonner eller celler uden at miste data   |   Runde uden formel ...
Super opslag: VLookup med flere kriterier    Multiple Value VLookup  |   VOpslag på tværs af flere ark   |   Fuzzy Lookup ....
Avanceret rulleliste: Opret hurtigt rulleliste   |  Afhængig rulleliste   |  Multivælg rulleliste ....
Column Manager: Tilføj et bestemt antal kolonner  |  Flyt kolonner  |  Skift synlighedsstatus for skjulte kolonner  |  Sammenlign områder og kolonner ...
Fremhævede funktioner: Grid fokus   |  Designvisning   |   Stor Formel Bar    Arbejdsbog & Ark Manager   |  Ressourcebibliotek (Autotekst)   |  Datovælger   |  Kombiner regneark   |  Krypter/Dekrypter celler    Send e-mails efter liste   |  Superfilter   |   Specielt filter (filter fed/kursiv/gennemstreget...) ...
Top 15 værktøjssæt12 tekst Værktøjer (tilføje tekst, Fjern tegn, ...)   |   50 + Chart Typer (Gantt kort, ...)   |   40+ Praktisk formler (Beregn alder baseret på fødselsdag, ...)   |   19 Indsættelse Værktøjer (Indsæt QR-kode, Indsæt billede fra sti, ...)   |   12 Konvertering Værktøjer (Tal til ord, Valutaomregning, ...)   |   7 Flet og del Værktøjer (Avancerede kombinere rækker, Opdel celler, ...)   |   ... og mere

Overlad dine Excel-færdigheder med Kutools til Excel, og oplev effektivitet som aldrig før. Kutools til Excel tilbyder over 300 avancerede funktioner for at øge produktiviteten og spare tid.  Klik her for at få den funktion, du har mest brug for...

Beskrivelse


Fanen Office bringer en grænseflade til et kontor med Office, og gør dit arbejde meget lettere

  • Aktiver redigering og læsning af faner i Word, Excel, PowerPoint, Publisher, Access, Visio og Project.
  • Åbn og opret flere dokumenter i nye faner i det samme vindue snarere end i nye vinduer.
  • Øger din produktivitet med 50 % og reducerer hundredvis af museklik for dig hver dag!
Comments (10)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Ragazzi perso cos' non posso correggere la singola cella...esiste un modo per ingrandire la singola cella una volta selezionata e lavorarci sopra ?
This comment was minimized by the moderator on the site
Hi,
This is great - thank you.

Would it be possible to only have this on a selection of cells on a sheet? For example, all cells in column A, or A3 to A26 for example?
Thank you!
Rhys
This comment was minimized by the moderator on the site
Hi,
I am using Mac-Air and it shows only the color when you click on ac particular cell, pls guide.
This comment was minimized by the moderator on the site
I have the same issue on my MBA M2 running Excel V16.62, blue background but no text seen
This comment was minimized by the moderator on the site
Error 1004 on line 15

Application.ActiveSheet.Pictures.Paste.Select

Why?, what could it be?
This comment was minimized by the moderator on the site
Hi, Mazzi,
The above code works well in my Excel workbook, which Excel version do you use?
This comment was minimized by the moderator on the site
I want to magnify when entering the data
This comment was minimized by the moderator on the site
Hi,
May be, there is no direct way for solving your problem, if you find a good method, please comment here.
This comment was minimized by the moderator on the site
this is cool, but i want it to run in all sheets, how can i do that?
This comment was minimized by the moderator on the site
Hi, Ahmet,
To apply this operation in all worksheets, you can use the below vba code. (You should put the code into the ThisWorkbook module).Please try it.
Private Sub Workbook_SheetSelectionChange(ByVal sh As Object, ByVal Target As Range)
Dim xRg As Range
Dim xCell As Range
Dim xShape As Variant
Set xRg = Target.Areas(1)
For Each xShape In ActiveSheet.Pictures
If xShape.Name = "zoom_cells" Then
xShape.Delete
End If
Next
If Application.WorksheetFunction.CountBlank(xRg) = xRg.Count Then Exit Sub
Application.ScreenUpdating = False
xRg.CopyPicture appearance:=xlScreen, Format:=xlPicture
Application.ActiveSheet.Pictures.Paste.Select
With Selection
.Name = "zoom_cells"
With .ShapeRange
.ScaleWidth 1.5, msoFalse, msoScaleFromTopLeft
.ScaleHeight 1.5, msoFalse, msoScaleFromTopLeft
With .Fill
.ForeColor.SchemeColor = 44
.Visible = msoTrue
.Solid
.Transparency = 0
End With
End With
End With
xRg.Select
Application.ScreenUpdating = True
Set xRg = Nothing
End Sub
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations