Passing 2 variables within same code

BrianExcel

Well-known Member
Joined
Apr 21, 2010
Messages
975
Right now I am employing the following code.

Code:
Sub sldrStaple_Scroll()
Dim sValue As Integer

sValue = Me.sldrStaple.Value

    With UserForm1.MultiPage1.Pages(3)
        ShowImageStaple "img" & sValue
    End With
End Sub

Sub ShowImageStaplePort(whichOneStaple As String)
    Dim objImage As Image, objImage2 As Image
    Dim cntl As Control

    For Each cntl In Me.frmStapling.Controls
        If Left(cntl.Name, 3) = "img" Then
            cntl.Visible = False
        End If
    Next cntl
        
    Set objImage = Me.Controls(whichOneStaple)
    objImage.Visible = True
    Set objImage = Nothing

End Sub

What this code does is basically display a different image each time the slider bar is moved.

What I need to do however, is display 2 images simultaneously using the slider.

In the first frame I have img0 - img5. In the second frame img6 - img11.

When I select the first tick on the slider, I need img0 and img6 both to show. The second tick shows img2 and img7, and so on.

Any thoughts on how I manipulate the code so it shows two variables? I would like to keep the code as minimal and simple as possible.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top