Magnifyihg glass for userform


Active Member
Jan 31, 2010
Hello there!

I have seen in this a cool magnifying glass by Jaafar and Ivan,but these magnifying glass operates only in excel sheet, do we have so far in this forum a magnifying glass meant for userform? The reason I am asking is because in my current project I have embedded images (jpeg files) in my userform with different images being loaded simultaneously. However, there are some infos I want to enlarged. I tried this magnifying glass by Jaafar and Ivan but I believe it is not meant for images in userforms...Can somebody help me find a magnifying glass for userform?



Some videos you may like

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.


Active Member
Jan 31, 2010
Hi There,

I found this code in other excel site. This code is meant for zooming the image in the userform. I have incorporated the code in my userform and is so far just do what I want. My problem is once I clicked command button 3, the image stays zoomed every time I load a new image. Can somebody re-write the code that if I clicked backed on the list box that the image will go back to the same size as it was when it initially loaded. I have set the image picturesize mode to stretch.

Thanks for the help....
Option Explicit
Const MAX_ZOOM = 4    ' 400% original size
Const MIN_ZOOM = 0.2  ' 20%  original size
Private m_sngWidth As Single
Private m_sngHeight As Single
Private m_sngZoom As Single
Private Sub CommandButton1_Click()
 m_sngZoom = m_sngZoom + 0.1
    If m_sngZoom > MAX_ZOOM Then m_sngZoom = MAX_ZOOM
    CommandButton1.Enabled = m_sngZoom <> MAX_ZOOM
    CommandButton2.Enabled = m_sngZoom <> MIN_ZOOM
    SetZoom m_sngZoom
End Sub
Private Sub CommandButton2_Click()
    m_sngZoom = m_sngZoom - 0.1
    If m_sngZoom < MIN_ZOOM Then m_sngZoom = MIN_ZOOM
    CommandButton2.Enabled = m_sngZoom <> MIN_ZOOM
    CommandButton1.Enabled = m_sngZoom <> MAX_ZOOM
    SetZoom m_sngZoom
End Sub
Private Sub CommandButton3_Click()
With Image1
            .AutoSize = True
           ' .Picture = LoadPicture(Name)
            m_sngHeight = .Height
            m_sngWidth = .Width
            .AutoSize = False
            .PictureSizeMode = fmPictureSizeModeStretch
            m_sngZoom = 1
            .Left = 1
            .Top = 1
        End With
        SetZoom m_sngZoom
End Sub

Private Sub ListBox1_Click()
Dim ProdFound As Range
    With Sheet3.Range("C:C")
        Set ProdFound = .Find(ListBox1.Value)
        If ProdFound Is Nothing Then
            MsgBox ("ITEM NOT FOUND!")
            ListBox1.Value = ""
            Exit Sub
            With Range(ProdFound.Address)
            UserForm2.TextBox32.Value = .Offset(0, 1)
            UserForm2.TextBox33.Value = .Offset(0, 2)
            UserForm2.TextBox34.Value = .Offset(0, 3)
            UserForm2.TextBox35.Value = .Offset(0, 5)
            UserForm2.TextBox36.Value = .Offset(0, 7)
            UserForm2.TextBox37.Value = .Offset(0, 9)
            UserForm2.TextBox38.Value = .Offset(0, 10)
            UserForm2.TextBox39.Value = .Offset(0, 6)
            UserForm2.TextBox40.Value = .Offset(0, 8)
            UserForm2.Label45.Caption = .Offset(0, 0)
            UserForm2.Label46.Caption = .Offset(0, 1)
            'TextBox22.Value = .Offset(0, 19)
            'TextBox21.Value = .Offset(0, 0)
            'Label40.BackColor = RGB(255, 255, 0)
            On Error Resume Next
            Image1.Picture = LoadPicture _
            ("C:\Documents and Settings\" & Environ("username") & "\Desktop\MOBIL\" & UserForm2.Label45.Caption & ".jpg")
            On Error GoTo 0
            End With
        End If
    End With
End Sub
Sub SetZoom(Zoom As Single)
    With Image1
        .Width = m_sngWidth * Zoom
        .Height = m_sngHeight * Zoom
    End With
    Label48.Caption = "Zoom " & Format(Zoom, "0%")
    With Frame8
        .ScrollHeight = Image1.Height + 2
        .ScrollWidth = Image1.Width + 2
    End With
End Sub

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Latest member

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...