提示:其他語言是Google翻譯的。 你可以訪問 English 版本。
登入
x
or
x
x
註冊
x

or

如何縮放或放大Excel中選定的單元格?

眾所周知,Excel具有縮放功能,可以幫助我們在整個工作表中增加單元格大小。 但是,有時候,我們只需要放大或放大所選的單元格。 我們有沒有什麼好的想法只能在工作表中放大選定的單元格?

用VBA代碼放大或放大所選單元格


用VBA代碼放大或放大所選單元格


可能在那裡沒有直接的方式讓我們在Excel中放大選定的單元格,但是,在這裡,我可以引入一個VBA代碼來處理這項工作,作為解決方法。 請做如下操作:

1。 右鍵單擊要自動放大所選單元格的工作表選項卡,然後選擇 查看代碼 從上下文菜單中,在打開的 Microsoft Visual Basic的應用程序 窗口中,將以下代碼複製並粘貼到空白模塊中:

VBA代碼:放大或放大選定的單元格:

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。 然後保存並關閉此代碼窗口,現在,當您選擇或單擊某些數據單元格時,單元格將自動放大為圖片,請參閱截圖:

注意:選中其他單元格後,所選單元格將變回原始大小。


Kutools for Excel解決了您的大多數問題,並使您的生產率提高了80%

  • 重用: 快速插入 複雜的公式,圖表 以及你以前用過的任何東西; 加密單元格 密碼; 創建郵件列表 並發送電子郵件...
  • 超級方程式酒吧 (輕鬆編輯多行文字和公式); 閱讀佈局 (輕鬆讀取和編輯大量單元格); 粘貼到過濾範圍...
  • 合併單元格/行/列 不丟失數據; 分裂細胞含量; 組合重複的行/列...防止重複的細胞; 比較範圍...
  • 選擇複製或唯一 行; 選擇空行 (所有細胞都是空的); 超級查找和模糊查找 在許多工作簿中; 隨機選擇......
  • 精確複製 多個單元格而不更改公式參考; 自動創建參考 多張表; 插入項目符號,複選框等等......
  • 提取文本,添加文本,按位置刪除, 刪除空間; 創建和打印分頁小計; 在單元格內容和註釋之間轉換...
  • 超級過濾器 (將過濾方案保存並應用到其他工作表); 高級排序 按月/週/日,頻率等; 特殊過濾器 用粗體,斜體......
  • 結合工作簿和工作表; 根據鍵列合併表; 將數據拆分為多個表格; 批量轉換xls,xlsx和PDF...
  • 超過300強大的功能。 支持Office / Excel 2007-2019和365。 支持所有語言。 在您的企業或組織中輕鬆部署。 全功能30天免費試用。
kte tab 201905

Office選項卡為Office提供選項卡式界面,使您的工作更輕鬆

  • 在Word,Excel,PowerPoint中啟用選項卡式編輯和閱讀,Publisher,Access,Visio和Project。
  • 在同一窗口的新選項卡中打開並創建多個文檔,而不是在新窗口中。
  • 通過50%提高您的工作效率,每天為您減少數百次鼠標點擊!
官方底部
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Mazzi · 8 months ago
    Error 1004 on line 15

    Application.ActiveSheet.Pictures.Paste.Select

    Why?, what could it be?
    • To post as a guest, your comment is unpublished.
      skyyang · 8 months ago
      Hi, Mazzi,
      The above code works well in my Excel workbook, which Excel version do you use?
  • To post as a guest, your comment is unpublished.
    ashraf · 11 months ago
    I want to magnify when entering the data
    • To post as a guest, your comment is unpublished.
      skyyang · 11 months ago
      Hi,
      May be, there is no direct way for solving your problem, if you find a good method, please comment here.
  • To post as a guest, your comment is unpublished.
    Ahmet · 1 years ago
    this is cool, but i want it to run in all sheets, how can i do that?
    • To post as a guest, your comment is unpublished.
      skyyang · 1 years ago
      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