I built an excel file with several userforms in VBA, which contain buttons (form controls). Usually i work with dock-station to connect my laptop to big screen (im my office). sometimes i open the file with no docking station (only laptop).
I opened today the file, and found out that the resolution is totally changed, the user forms become so big and in all buttons the text inside are wrapped to right.
Please your support to know How can i correct the problem?
thanks
This is an issue caused by the File being open while your native screen resolution changes (and possibly only when this also changes the Aspect Ratio) - the most common reason for that being connecting or disconnecting a Laptop to/from an external screen (in this case, via your Docking Station)
There are 2 forms this issue takes: either the Button stays the same size, and but the contents (text, images, etc) are scaled up/down while anchored in the top-left - which is what has happened here - or the contents stay the same size, but the button itself gets larger/smaller until it either covers the whole sheet or is too small to click.
In my experience, the only way to fix the buttons is adjust them, and force Excel to redraw the shape instead of "remembering" what it should look like. You can do this manually, but I will try to track down some code to "reset" buttons for you. here is some code to do things for you.
(For a UserForm, you may just be able to call Me.Repaint to force a redraw without needing to bother with the resizing - but I haven't tested that as I can never get this issue to happen on-demand >_<)
UserForm Button Fix
Sub FixButtonFormat(ByRef Button As Control)
Dim Top As Double, Left As Double, Width As Double, Height As Double, FontName As String, FontSize As Double
Top = Button.Top
Left = Button.Left
Width = Button.Width
Height = Button.Height
FontName = Button.Object.Font.Name
FontSize = Button.Object.Font.Size
'Scale Button up slightly
Button.Top = Top - 1
Button.Left = Left + 1
Button.Width = Width - 2
Button.Height = Height + 2
Button.Object.Font.Size = FontSize + 1
DoEvents
UserForm1.Repaint
DoEvents
'Reset button to original size
Button.Top = Top
Button.Left = Left
Button.Width = Width
Button.Height = Height
Button.Object.Font.Name = FontName
Button.Object.Font.Size = FontSize
End Sub
Worksheet Button Fix
Sub FixButtonFormat(ByRef Button As Shape)
If Button.Type <> msoFormControl And Button.Type <> msoOLEControlObject Then Exit Sub
Dim Top As Double, Left As Double, Width As Double, Height As Double, FontName As String, FontSize As Double
Dim Screen As Boolean
Screen = Application.ScreenUpdating
Top = Button.Top
Left = Button.Left
Width = Button.Width
Height = Button.Height
If Button.Type = msoFormControl Then 'Form Control
FontName = Button.OLEFormat.Object.Font.Name
FontSize = Button.OLEFormat.Object.Font.Size
ElseIf Button.Type = msoOLEControlObject Then 'ActiveX Control
FontName = Button.DrawingObject.Object.Font.Name
FontSize = Button.DrawingObject.Object.Font.Size
End If
'Scale Button up slightly
Button.Top = Top - 1
Button.Left = Left + 1
Button.Width = Width - 2
Button.Height = Height + 2
If Button.Type = msoFormControl Then 'Form Control
Button.OLEFormat.Object.Font.Size = FontSize + 1
ElseIf Button.Type = msoOLEControlObject Then 'ActiveX Control
Button.DrawingObject.Object.Font.Size = FontSize + 1
End If
If Not Screen Then
Application.ScreenUpdating = True
DoEvents
Application.ScreenUpdating = False
Else
DoEvents
End If
'Reset button to original size
Button.Top = Top
Button.Left = Left
Button.Width = Width
Button.Height = Height
If Button.Type = msoFormControl Then 'Form Control
Button.OLEFormat.Object.Font.Name = FontName
Button.OLEFormat.Object.Font.Size = FontSize
ElseIf Button.Type = msoOLEControlObject Then 'ActiveX Control
Button.DrawingObject.Object.Font.Size = FontSize
Button.DrawingObject.Object.Font.Name = FontName
End If
End Sub
In Office365, I had the same issue (I must have detached my laptop from a docking station while a VBA form was showing on an external monitor) where everything became supersized.
I went into the code and opened up the form object to manually resize everything - when I clicked the bottom right corner of the UserForm rectangle to resize it, all the controls on the form instantly corrected themselves back down to proper size to match to my current screen resolution, and snapped back to the upper left of the form. All I had to do was reduce the UserForm to match the corrected controls.
Related
I have a UserForm that reads data from a file and dynamically fills a Frame control with other Frame controls that themselves are filled with Labels describing that data. So, there's one big Frame control — DisplayFrame — put onto the UserForm using the Toolbox, and at runtime when the file is opened other smaller Frame controls — cFrame1, cFrame2, etc — are added inside the DisplayFrame control, with labels like NameLabel, DateLabel, added to each cFrame.
I'd like the user to be able to select any of the cFrames, then click a button on the user form and for another window to open with all of the data inside the labels (plus additional data) in that cFrame.
By select, I mean that when the user clicks on ANY of the labels inside a particular cFrame — or the cFrame itself — the color of the cFrame and all its elements change and that particular cFrame is recorded as being the current selection. The tricky part, I think, is that the color of any previously selected cFrame should change back to the default color.
I've created a Class called FrameGroup to hold all the cFrames that are created. I defined the click event of the FrameGroup class to change color when it is selected and to hold the data of the cFrame just selected.
<<Class FrameGroup>>
Public WithEvents FrameGroup As Frame
Private cName As String
Private cDay As String
Private Sub FrameGroup_Click()
cName = FrameGroup.Controls(0).Caption
cDay = FrameGroup.Controls(1).Caption
' If current cFrame was selected before, then deselect it
' by returning to default color
If FrameGroup.BackColor = &H8000000D Then
FrameGroup.BackColor = &H80000005
FrameGroup.Controls(0).BackColor = &H80000005
FrameGroup.Controls(1).BackColor = &H80000005
Else
' Select cFrame by changing color
FrameGroup.BackColor = &H8000000D
FrameGroup.Controls(0).BackColor = &H8000000D
FrameGroup.Controls(1).BackColor = &H8000000D
End If
End Sub
<<Code for UserForm>>
Dim FrameList() As New FrameGroup
Private Sub UserForm_Initialize()
Dim TextLine As String
Dim Text() As String
Dim LineNo As Integer
' Open file containing saved Color Scales
Open file For Input As #1
LineNo = 0
Do Until EOF(1)
Line Input #1, TextLine
Text = Split(TextLine, ",")
' Making CFrame
Dim currCFrame As Frame
Set currCFrame = DisplayFrame.Controls.Add("Forms.Frame.1", "cFrame" & LineNo, True)
' Adding labels
Dim NameLabel As Control
Set NameLabel = currCFrame.Controls.Add("Forms.Label.1", "Name" & LineNo, True)
Dim DateLabel As Control
Set DateLabel = currCFrame.Controls.Add("Forms.Label.1", "DateCreated" & LineNo, True)
' Increment line number
LineNo = LineNo + 1
' Adding new frame to frame group
ReDim Preserve FrameList(1 To LineNo + 1)
Set FrameList(LineNo).FrameGroup = currCFrame
Loop
' Close file once we are done reading color scales from it
Close #1
End Sub
What happens is that only when the cFrame is clicked does anything happen--not when any of the labels inside are clicked. And I don't know how to make it so that when a cFrame is clicked, the color of the previously selected cFrame is also changed to the default color.
I've tried to look up how to do something like this, and solutions like this seem to bring up a different class module for cFrame and its labels and a intermediary class handling communications between two classes, but this seems complicated. If I followed this design, I'd probably need another intermediary between cFrame and the button being clicked to load data, right? I don't want to make this more complicated than it needs to be, but I also would like to create a sustainable and robust solution. Any help would be appreciated.
Label Click put in and clicking in another frame gives the other frames the default color,
Tried to minimize the adjustments to your code below:
'<<Class FrameGroup>>
Public WithEvents FrameGroup As MSForms.Frame
Public WithEvents LabelGroup As MSForms.Label
Private cName As String
Private cDay As String
Private Sub FrameGroup_Click()
Dim ctl As MSForms.Control
cName = FrameGroup.Controls(0).Caption
cDay = FrameGroup.Controls(1).Caption
For Each ctl In FrameGroup.Parent.Controls
ctl.BackColor = &H80000005
Next
FrameGroup.BackColor = &H8000000D
FrameGroup.Controls(0).BackColor = &H8000000D
FrameGroup.Controls(1).BackColor = &H8000000D
End Sub
Private Sub LabelGroup_Click()
Dim ctl As MSForms.Control
cName = LabelGroup.Parent.Controls(0).Caption
cDay = LabelGroup.Parent.Controls(1).Caption
For Each ctl In LabelGroup.Parent.Parent.Controls
ctl.BackColor = &H80000005
Next
LabelGroup.Parent.BackColor = &H8000000D
LabelGroup.Parent.Controls(0).BackColor = &H8000000D
LabelGroup.Parent.Controls(1).BackColor = &H8000000D
End Sub
'<<Code for UserForm>>
Dim FrameList() As New FrameGroup
Private Sub UserForm_Initialize()
Dim TextLine As String
Dim Text() As String
Dim LineNo As Integer
' Open file containing saved Color Scales
Open file For Input As #1
LineNo = 0
Do Until EOF(1)
Line Input #1, TextLine
Text = Split(TextLine, ",")
' Making CFrame
Dim currCFrame As Frame
Set currCFrame = DisplayFrame.Controls.Add("Forms.Frame.1", "cFrame" & LineNo, True)
' Adding labels
Dim NameLabel As Control
Set NameLabel = currCFrame.Controls.Add("Forms.Label.1", "Name" & LineNo, True)
Dim DateLabel As Control
Set DateLabel = currCFrame.Controls.Add("Forms.Label.1", "DateCreated" & LineNo, True)
' Increment line number
LineNo = LineNo + 1
' Adding new controls to frame group
ReDim Preserve FrameList(1 To 3 * (LineNo + 1))
Set FrameList(3 * (LineNo) + 1).FrameGroup = currCFrame
Set FrameList(3 * (LineNo) + 2).LabelGroup = DateLabel
Set FrameList(3 * (LineNo) + 3).LabelGroup = NameLabel
Loop
' Close file once we are done reading color scales from it
Close #1
End Sub
The Click event of a Frame control is only raised when you click the border of that said frame or its blank area. If you click a Label within a Frame, this control has it's own area. If you click this area, then that's the label's Click event that is raised, not the frame's.
The followin picture shows you the area that belongs to the Label (grey) vs the area that belong to the Frame (red).
I am trying to make a system that adds checkboxes (on the click of a button) if there are any new worksheets added to the workbook. My code is below, It was able to create the checkboxes until I tried changing the location, so I am assuming that the reason it doesn't work is due to that.
Private Sub Update_Click()
Dim cb As CheckBox
Dim Exists As Boolean
'I think these location/ dimension variables are perhaps wrong (I'm not sure what values they take)
Dim TopLocation As Double
Dim LeftLocation As Double
Dim Width As Double
Dim Height As Double
For Each ws In ActiveWorkbook.Worksheets
'This loop is simply to stop it from making duplicate checkboxes
Exists=False
For Each cb In ThisWorkbook.Worksheets("Summary").CheckBoxes
If cb.name = ws.name Or ws.name = "Summary" Or ws.name = "Price List (2)" Then
Exists = True
End If
Next
If Exists = False Then
TopLocation = 0
LeftLocation = 0
Width = 0
Height = 0
'The following loop is an attempt to find the checkbox that is furthest down the page, the problem is that I am not too familiar with the location attribute so am just assuming that it increases as you move down the page
For Each cb In ThisWorkbook.Worksheets("Summary").CheckBoxes
If cb.Top > TopLocation Then
TopLocation = cb.Top
End If
If cb.Left > LeftLocation Then
LeftLocation = cb.Left
End If
If cb.Width > Width Then
Width = cb.Width
End If
If cb.Height > Height Then
Height = cb.Height
End If
Next
'The following is where I believe the problem to be, I thought that I could simply use the variables I had created to place the new one in this location
With ThisWorkbook.Worksheets("Summary").CheckBoxes.Add(LeftLocation, TopLocation + Height, Width, Height)
.name = ws.name
.Caption = ws.name
End With
End If
Next ws
End Sub
I am thinking that perhaps this is a misunderstanding of the checkboxes syntax and was hoping that someone could help me to understand where I have gone wrong. Any help is appreciated, Thanks :)
you have two typos..
in the line
With ThisWorkbook.Worksheets("Summary").CheckBoxes.Add(LocationLeft, LocationTop + Height, Width, Height)
the vars should be LeftLocation (not LocationLeft ) and TopLocation (not LocationTop)
good luck
I have macro assigned to a rectangle shape that goes to the next sheet in my workbook.
I'm trying to add a press down and up effect to this rectangle.
When I use this code, the rectangle is only pressed down then then the next sheet is activated, and if I returned back to the previous sheet, the rectangle is released.
Wht I need is that the rectangle is pressed down and then released before going to the next sheet.
Dim MyButton As Shape
Dim oHeight, oWidth, cHeight, cWidth As Double
Dim oTop, oLeft As Long
Public Sub PressButton()
Set MyButton = ActiveSheet.Shapes(Application.Caller)
With MyButton
'Record original button properties.
oHeight = .Height
oWidth = .Width
oTop = .Top
oLeft = .Left
'Button Down (Simulate button click).
.ScaleHeight 0.9, msoFalse
.ScaleWidth 0.9, msoFalse
cHeight = .Height
cWidth = .Width
.Top = oTop + ((oHeight - cHeight) / 2)
.Left = oLeft + ((oWidth - cWidth) / 2)
End With
'Set MyButton variable to Nothing to free memory.
Set MyButton = Nothing
End Sub
Public Sub ReleaseButton()
Set MyButton = ActiveSheet.Shapes(Application.Caller)
With MyButton
'Button Up (Set back to original button properties).
.Height = oHeight
.Width = oWidth
.Top = oTop
.Left = oLeft
End With
'Set MyButton variable to Nothing to free memory.
Set MyButton = Nothing
End Sub
Public Sub NextPage()
PressButton
Application.Wait (Now + TimeSerial(0, 0, 1))
ReleaseButton
Dim ws As Worksheet
Set ws = ActiveSheet
Do While Not ws.Next.Visible = xlSheetVisible
Set ws = ws.Next
Loop
With ws.Next
.Activate
.Range("A1").Select
End With
End Sub
You're better off using a 'Command Button': shapes and rectangle objects don't really support the event-driven 'On Click' functionality you need here: calling an associated macro is pretty much all that they do.
However, you may well be stuck with that shape as your interface (support for ActiveX command buttons is very poor in 64-bit environments), so here goes...
Background: how to make a button look like a button:
Most shapes have a 'Shadow' property, and an outside shadow cast by a light source from a 45-degree angle (from the top-left corner) gives a 'raised' effect. Conversely, an inside shadow cast from the opposite angle (from a light source off the bottom-right corner) gives a 'sunken' effect.
In practice, an inside shadow for both is good enough: just change the angle.
In VBA, the 'angle' of the light source for your shape's shadow is given as X and Y offsets, and 45 degrees corresponds to 1.14142:
Dim oShape As Excel.Shape
Dim oShadow As Excel.ShadowFormat
Set oShape = ActiveSheet.Shapes(i)
Set oShadow = oShape.Shadow
' Shadow cast by light from above-right at 45 degrees for a 'raised' effect:
oShadow.OffsetX = Sqr(2)
oShadow.OffsetY = Sqr(2)
' Shadow cast by light from above-right at minus 45 degrees for a 'sunken' effect:
oShadow.OffsetX = -Sqr(2)
oShadow.OffsetY = -Sqr(2)
...And that's the code for your click 'up' and click 'down' button state.
I Strongly recommend that you use the built-in dialogs to set the shape's fill colour and the shadow's size, transparency and blur. For your reference, the settings I use for a smart 'semi-flat' light grey button are listed below - but I do not recommend that you set them in VBA code, as these formats will not be applied in the order you expect, and the button will not look like the 'clean' shape you can build using the UI dialogs:
' Light-grey button with a slightly darker 'softened' border
oShape.Fill.ForeColor.RGB = &HD8D8D8
oShape.Line.ForeColor.RGB = &HC0C0C0
oShape.Line.Weight = 2
oShape.Line.Transparency = 0.75
' Use the shape's shadow to give a 'raised button' effect:
oShadow.Style = msoShadowStyleInnerShadow
oShadow.Visible = True
oShadow.Blur = 2
oShadow.Size = 100
oShadow.Transparency = 0.5
' Shadow cast by light from above-right at 45 degrees for a 'raised' effect:
oShadow.OffsetX = Sqr(2)
oShadow.OffsetY = Sqr(2)
You can also use the 3-D effects dialog, but this works by a 'chisel' effect for most shapes (including your rectangle): I haven't found any predefined 'raised' or 'sunken' three-D styles for shapes.
Major Edit:
Guess who's looking at the job of replacing all the Active-X control buttons on all the tactical spreadsheet tools before the 64-Bit Office rollout renders them inoperable?
So your question just became very, very interesting indeed. Here's what I'm doing about that:
Generic 'Button Click' code for using Excel 'Shape' objects to call a VBA Macro instead of ActiveX controls.
This is what I'm using instead of ActiveX buttons: text labels, rectangles and images, placed into the worksheet using the 'Insert' menu on the Ribbon.
These objects are all Excel 'Shapes', they can all be associated with a named macro, and they have a common 'shadow' effect that serves as a 'raised button' 3D effect.
The example below is a function call from an image (it's a 32*32 icon for a database, with a question mark) embedded as a shape on a worksheet. I gave this ersatz control button a meaningful name, and I named the macro [Name]_Click(), because I'm replacing the existing 'Click' event procedures.
So this macro is a public subroutine on a worksheet identified with a code name, - users can 'rename' the sheet, changing the user-readable label, but they won't rename the underlying VBA class module - and it's visible as MySheetCodeName.img_TestDefaultDSN_Click() in the 'assign macro' list when you right-click the shape.
..That's why it's Public (not Private, as the automatically-created event procedure stubs for ActiveX controls will be): private subs aren't visible in the 'Assign Macro' list.
Public Sub img_TestDefaultDSN_Click()
ClickDown Me.Shapes("img_TestDefaultDB")
ShowDBStatus "EOD_Reports_DSN"
ClickUp Me.Shapes("img_TestDefaultDB")
End Sub
This calls a pair of generic 'Click Down' and 'Click Up' subroutines, in a regular code module:
Public Function ClickDown(objShape As Excel.Shape)
On Error Resume Next
'Recast the button shadow from bottom-right to top-left:
With objShape.Shadow
.Visible = msoFalse
.OffsetX = -1.2
.OffsetY = -1.2
.Visible = msoTrue
.Blur = 1
.Size = 99
.Transparency = 0.75
.Style = msoShadowStyleInnerShadow
.Obscured = msoFalse
End With
'Darken the button face slightly:
If objShape.Type = msoPicture Then
With objShape.PictureFormat
.Brightness = .Brightness - 0.01
End With
Else
With objShape.Fill
.Visible = msoTrue
.ForeColor.Brightness = .ForeColor.Brightness - 0.01
End With
End If
End Function
Public Function ClickUp(objShape As Excel.Shape)
On Error Resume Next
'Restore the button face to it's default brightness:
With objShape.Shadow
.Visible = msoFalse
.OffsetX = 1.2
.OffsetY = 1.2
.Visible = msoTrue
.Blur = 1
.Size = 99
.Transparency = 0.75
.Style = msoShadowStyleInnerShadow
.Obscured = msoFalse
End With
'Restore the button shadow to bottom-right:
If objShape.Type = msoPicture Then
With objShape.PictureFormat
.Brightness = .Brightness + 0.01
End With
Else
With objShape.Fill
.Visible = msoTrue
.ForeColor.Brightness = .ForeColor.Brightness + 0.01
End With
End If
End Function
You may well have your own preferences for the appearance of a 'control button', but this works for me.
Note that the 'Click Down' effect is never seen if 'Click Up' follows immediately: nor even if a 'Sleep' or an 'Application Wait' statement separates them - you'll only see it if there's real code with a user-detectable elapsed time or a modal dialog.
Is it possible to use Private subs. You only need to change the way you call the subroutines. To call private sub, even located in another code module, you have to use:
Application.Run "[ModuleName.]MacroName"[, arg1] [,arg2...],
Everything is in details explained here:
https://wellsr.com/vba/2015/excel/3-ways-to-call-a-private-sub-from-another-module/
I am trying to create labels in a Frame during runtime with VBA. The problem is, I want to be able to click them once they are created. So this is what I made : (my labels are attached to a Frame)
Set TheLabel = Frame.Controls.Add("Forms.Label.1", Visible = True)
With TheLabel
.Name = "Label" & i
.Caption = gTab(i, 2) & "_ " & gTab(i, 0) & Temp
.Left = 6 + gTab(i, 2) * 12
.Top = 12 + 16 * i
.Height = 12
.Width = 200
End With
Where i is an integer (it's the number of the current label).
With this code, I imagine the name of my Label is now Label1, Label2 etc.
But even with this piece of code:
Private Sub Label1_Click()
Frame.Height = 200
End Sub
It doesn't seem to work.
Thanks a lot!
To add controls to a userform at runtime, with code behind the controls, see this answer and this one as well.
I'm trying to code a dynamic/conditional userform that changes the controls on the userform based on what is entered into certain input fields of the userform. The whole idea of my VBA Excel project is to take 2 data series (say, x and y) and manipulate them according to functionalities queried by the user. The specific part of my userform that causes the problem is that part where the user can choose which type of the series he/she wants to pick for either variable (x or y).
For you to understand my issue as quickly as possible, I uploaded an excel file to the following link:
http://www26.zippyshare.com/v/51719800/file.html
To keep things simple, I isolated the problem causing code, cut out all other macros and limited the userform to the controls that cause the error. To run it, click on the "Initialize" button located in the top left corner of the first tab.
When initialized, the userform contains 6 controls: 2 labels, 2 comboboxes, and 2 frames. The functionality of the uploaded test file is limited: For both series (independent series (or x) and dependent series (y)) when you click on "Replacement" a number of controls should be added to the frame corresponding to the series.
The weird thing is that this works without a problem for the first(/independent) series, but for the second(/dependent) series I get
Run-time-error '-2147417848(80010108): Automation error. The object
invoked has disconnected from its clients.
even though both instances call the very same procedure and in both instances the arguments passed to the function are valid. I tried the code on coworkers' laptops as well, but get the same error.
The code of the procedure that causes the error is given below. The procedure simply adds a control to a certain target frame based on arguments passed to the function. The exact line causing the crash is:
Set daFrame = dest.Controls.Add("Forms.Frame.1", name)
What is also weird is that the error only occurs for the case where we are creating a frame. Adding all the other controls e.g. ListBoxes, Labels, etc. (even for the second series) is not a problem.
Public Sub add_control(dest As MSForms.Frame, ht As Integer, wdt As Integer, tp As Integer, lft As Integer, typ As String, _
name As String, Optional capt As String)
Dim daFrame As MSForms.Frame
Dim daButton As MSForms.OptionButton
Dim daList As MSForms.ListBox
Dim daLabel As MSForms.Label
Dim daBox As MSForms.ComboBox
Select Case typ
Case "Frame"
Set daFrame = dest.Controls.Add("Forms.Frame.1", name)
With daFrame
.Height = ht
.Width = wdt
.Top = tp
.Left = lft
.Caption = capt
End With
Case "ListBox"
Set daList = dest.Controls.Add("Forms.Listbox.1", name)
With daList
.Height = ht
.Width = wdt
.Top = tp
.Left = lft
End With
Case "OptionButton"
Set daButton = dest.Controls.Add("Forms.OptionButton.1", name)
With daButton
.Height = ht
.Width = wdt
.Top = tp
.Left = lft
.Caption = capt
End With
Case "Label"
Set daLabel = dest.Controls.Add("Forms.Label.1", name)
With daLabel
.Height = ht
.Width = wdt
.Top = tp
.Left = lft
.Caption = capt
End With
Case "ComboBox"
Set daBox = dest.Controls.Add("Forms.ComboBox.1", name)
With daBox
.Height = ht
.Width = wdt
.Top = tp
.Left = lft
End With
End Select
End Sub
Please help me guys, I really appreciate any input. Also, if there is a way/programming style to guard against such weird behavior/erros, please let me know. Of course, I searched this forum and google for any hints, but it seems that this problem is rather code specific. In any case, I couldn't find anything helpful on the web.
Cheers
I haven't really figured out what is the real cause, but it is not the code - the real issue must be in the DepFrame. If you simply delete it and copy&rename IndFrame all works fine. But you probably figured out that already - I also wanted to tell you that you have a mistake in Dependent_change sub. You are using value of Independent instead of Dependent in the last ElseIf.
Private Sub Dependent_Change()
If Dependent.Value = "Replacement" Then
DepFrame.Caption = "Replacement"
Call rearrange_frame("Replacement2")
ElseIf Dependent.Value = "Futures" Then
DepFrame.Caption = "Futures"
Call rearrange_frame("Futures2")
here: ElseIf Independent.Value = "Spread" Then
DepFrame.Caption = "Spread"
src = 2
End If
End Sub