VBA Userform with inactive workbook

dado6612

Well-known Member
Joined
Dec 4, 2009
Messages
591
Hello all,
I have an Userform which starts up when Workbook is open, and the workbook gets minimized.
Userform is show modeless so other open workbooks could be handled
Code:
Private Sub Workbook_Open()ActiveWindow.WindowState = xlMinimized
Workbooks("New BOM Maker Userform.xlsm").Activate
UserForm1.Show vbModeless
End Sub
The Userform consist of a MultiPage with a few tabs, on which each has some comboboxes, textboxes and listboxes
They are all connected to the workbook one way or another, either getting the value from a cell with a formula, or putting a value in other cell, getting rowsourse from named range, handling the ranges via copying, etc..

An example of one of such codes
Code:
Private Sub ComboBox3_Change()
With Workbooks("Userform.xlsm")
Workbooks("Userform.xlsm").Sheets("Order").Range("B4") = Me.ComboBox3.Value
If ComboBox3 = "Split" Then
ComboBox10.Visible = True
ComboBox11.Visible = True
Me.Width = 495
MultiPage1.Width = 475
ComboBox4.Value = "8"
Else
ComboBox10 = ""
ComboBox11 = ""
ComboBox10.Visible = False
ComboBox11.Visible = False
MultiPage1.Width = 372
Me.Width = 395
If ComboBox3 = "Offset" Then
    ComboBox8 = ""
    ComboBox10 = ""
    ComboBox11 = ""
    ComboBox5 = "Offset"
Else
ComboBox9 = ""
ComboBox10 = ""
End If
End If
Sheets("Order").Calculate
Me.ComboBox4.RowSource = Workbooks("Userform.xlsm").Sheets("Order").Range("D5").Value
Me.ComboBox5.RowSource = Workbooks("Userform.xlsm").Sheets("Order").Range("D7").Value
TextBox3 = Workbooks("Userform.xlsm").Sheets("Order").Range("b14").Value
End With
End Sub

I've tried with this
Code:
Private Sub ComboBox1_Change()
[B]Workbooks("Userform.xlsm").Activate[/B]
[B]Worksheets("Order").Select[/B]
Workbooks("Userform.xlsm").Sheets("Order").Range("b2") = ComboBox1.Value
Workbooks("Userform.xlsm").Sheets("Order").Calculate
On Error GoTo row3
Me.ComboBox3.RowSource = Workbooks("Userform.xlsm").Sheets("Order").Range("D4").Value
row3:
On Error GoTo row4
Me.ComboBox4.RowSource = Workbooks("Userform.xlsm").Sheets("Order").Range("D5").Value
row4:
TextBox3 = Workbooks("Userform.xlsm").Sheets("Order").Range("b14").Value
End Sub

The error I mostly get is out of the range when it tries to deal with a cell in any way.

All of that works fine if workbook stays active in the background or if it is the only open workbook in the application
As soon as other workbook is activated, userform breaks as it can't get the source for it's objects
Any way to avoid and bypass this?
Thank you
 
Okay did the label thing with select case, that worked.. so far all good, hope all my problems are fixed
thanks fluff for the help
 
Upvote 0

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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