Error Opening UserForm...

MistakesWereMade

Board Regular
Joined
May 22, 2019
Messages
103
I try to open my UserForm and for some reason it is erroring saying permission denied... Any ideas?

Error says it has to do with worksheet code line 'UserForm1.Show'

I have very similar issue to this guy here... We used the same tutorial and wanted our program to allow more than just the first selection.

https://stackoverflow.com/questions...value-only-excel-vba?answertab=active#tab-top

The tutorial we both used was:

https://trumpexcel.com/excel-drop-down-list-with-search-suggestions/

Worksheet Code:
Code:
Private Sub Workbook_Open()


    Application.Visible = True
    UserForm1.Show
    
End Sub

Userform Code:
Code:
Dim ListCB As Variant


Private Sub UserForm_Initialize()


  Dim TmpText As String
  If Not IsArray(Sheets("Data").Range(Names("DropDownList"))) Then
    temptext = Worksheets("Data").Range("E2").Value
    Worksheets("Data").Range("E2").Value = ""
  End If
  ListCB = Sheets("Data").Range(Names("DropDownList"))
  If Len(temptext) Then Worksheets("Data").Range("E2").Value = temptext
  GetCBList
  
End Sub


Sub GetCBList()


  Dim b As Variant, i As Long
  Dim a() As Variant: ReDim a(UBound(ListCB))
  For Each b In ListCB
    If Len(b) Then
      If InStr(1, b, ComboBox1.Value, vbTextCompare) > 0 Or ComboBox1.Value = "" Then: a(i) = b: i = i + 1
    End If
  Next
  If i > 0 Then ReDim Preserve a(i - 1)
  ComboBox1.List = a
  
End Sub


Private Sub ComboBox1_Change()


  GetCBList
  ComboBox1.DropDown
  Worksheets("Data").Range("E2").Value = ComboBox1.Value
  
End Sub
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Well... the initialize calls GetCBList which causes a combobox change which calls GetCBlist… seems recursive. U can add some Boolean to avoid this occurring. HTH. Dave
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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