-
Frame visible properties
I have 4 frames on a userform. I have a button on sheet 1, 2, 3, 4. How can I call a userform and make visible only the frame that corresponds to the sheet the button was used.
example...
If I'm on sheet1 and I click the button to display the userform, only frame1 should be visible. All other frames (2,3,&4) should be invisible.
If I'm on sheet2 and I click the button to display the userform, only frame2 should be visible. All other frames (1,3,&4) should be invisible.
etc.
Thanks for you help
-
You could add an argument to the sub that shows the userform:
In your form place this code:
[vba]Option Explicit
Public Frame2Show As Integer
Public Sub Initialize()
Dim iFrame As Integer
For iFrame = 1 To 4
With Me.Controls("Frame" & iFrame)
If iFrame = Frame2Show Then
.Visible = True
Else
.Visible = False
End If
End With
Next
End Sub
[/vba]
The sub to show the form:
[vba]Sub ShowForm(iFrame As Integer)
Dim ufForm As UserForm1
Set ufForm = New UserForm1
With ufForm
.Frame2Show = iFrame
.Initialize
.Show
End With
End Sub
[/vba]
Last edited by Aussiebear; 04-18-2011 at 03:06 AM.
Reason: Adjusted to use the correct tags around the code section
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules