提示:其它语言是由 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。 支持所有语言。 在您的企业或组织中轻松部署。 全功能60天免费试用。
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 · 7 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 · 7 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 · 10 months ago
    I want to magnify when entering the data
    • To post as a guest, your comment is unpublished.
      skyyang · 10 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