Zoom Microsoft Excel Cell with Macro

When we’re demonstrating our report to our client or boss maybe sometime we need to focus on a cell in Microsoft Excel project. And as we know Microsoft Excel doesn’t give the builtin function to zoom only a cell.

So I will share to make it with Macro.

OK, Microsoft Excel can give us flexibility to make our own tool with Macro, just follow these steps to make it.

  1. Open Microsoft Excel, you may open it by click Start -> All Programs -> Microsoft Excel or click Start -> Run menu then type excel in textbox then press Enter key.
    Open Excel
  2. To make a macro, click Tools -> Macro -> Visual Basic Editor menu.
    Macro menu
  3. After Visual Basic Editor is open, make a module with click Insert -> Module menu.
    Insert a module
  4. Then type this code in its workspace:
    Sub ZoomIt()
    Dim my_range As Range
    Dim zoom_in As Single
    Set my_range = Selection
    zoom_in = 5
    
    For Each p In ActiveSheet.Pictures
        If p.Name = "ZoomIt" Then
            p.Delete
            Exit For
        End If
    Next
    
    my_range.CopyPicture appearance:=xlScreen, Format:=xlPicture
    ActiveSheet.Pictures.Paste.Select
        With Selection
            .Name = "ZoomIt"
            With .ShapeRange
                .ScaleWidth zoom_in, msoFalse, msoScaleFromTopLeft
                .ScaleHeight zoom_in, msoFalse, msoScaleFromTopLeft
                With .Fill
                    .ForeColor.SchemeColor = 9
                    .Visible = msoTrue
                    .Solid
                End With
            End With
        End With
    my_range.Select
    
    Set my_range = Nothing
    End Sub

    Type the code

  5. Recheck the code and if make sure that the code is right (you may copy then paste the code from above and if you’re ensuring it right click Debug -> Compile VBA Project menu.
    Compile the script
  6. Close the Visual Basic Editor window.
  7. Right click on empty space in Microsoft Excel toolbar area then click Customize menu.
    Customize menu
  8. Click Commands tab and click Macros category then click Custom Button commands.
    Customize the button
  9. Drag it to toolbar that you want (I choose to put it beside Help icon).
    Drag onto toolbar
  10. And if you’re doing it right you can see a new icon on toolbar.
    The button
  11. Then assign the macro with right click the icon and click Assign Macro menu.
    Right click the icon
  12. Choose ZoomIt Macro in list then click OK button.
    Assign the macro
  13. To make it more user friendly, right click the icon and change its name and view it in Image & Text mode.
    Change its name
  14. And look the icon looking now.
    The final button
  15. Now, try to type some data in cell.
    Type the data
  16. Try to move cursor on a cell then click the macro icon on toolbar.
    Click macro button
  17. Here is the result.
    Result
  18. To close the zoomed cell just click the zoomed cell then press Delete key.
    Back to normal mode

(article no: 0099)

Leave a Comment