ComboBox Permission Error

nubranger

Board Regular
Joined
Dec 23, 2019
Messages
53
Office Version
  1. 365
Platform
  1. Windows
I am getting "Permission Denied" error when I change the value of one of the ComboBoxes. Error happens starting on the 3rd change. I am getting error on these lines

VBA Code:
Worksheets("Settings").ComboBox1.List = Split(Left2Use, ",")
Worksheets("Settings").ComboBox2.List = Split(Left2Use, ",")


Full Code

VBA Code:
Private Sub Workbook_Open()

  Worksheets("Settings").ComboBox1.Value = Null
  Worksheets("Settings").ComboBox2.Value = Null
   
Worksheets("Settings").ComboBox1.List = Split(" ,1,2,3,4,5", ",")
Worksheets("Settings").ComboBox2.List = Split(" ,1,2,3,4,5", ",")

End Sub

Sub ComboBox1_Change()
   ManageDropDowns (1)
End Sub

Sub ComboBox2_Change()
   ManageDropDowns (2)
End Sub


Sub ManageDropDowns(IDNum As Integer)

   Dim UsedList As String, FullList As String, Left2Use As String
   Dim FullArray As Variant, UsedArray(1 To 2) As String

   UL1 = ""
   UL1 = UL1 & IIf(Trim(ComboBox2.Value) = "", "", "" & Trim(ComboBox2.Value) & ",")
   While Right(UL1, 1) = ","
      UL1 = Left(UL1, Len(UL1) - 1)
   Wend

   UL2 = ""
   UL2 = UL2 & IIf(Trim(ComboBox1.Value) = "", "", "" & Trim(ComboBox1.Value) & ",")

   FullList = "1,2,3,4,5"
   FullArray = Split(FullList, ",")
   Left2Use = " ,"

   If IDNum <> 1 Then
      UsedList = UL1
      Left2Use = " "  ' Space
      For i = 0 To UBound(FullArray)
         iTxt = Trim("" & i + 1)
         If Not (InStr(1, UsedList, iTxt) > 0) Then
            ' Not Already Used - Add it to Left2Use
            Left2Use = Left2Use & "," & iTxt
         End If
      Next i
      Worksheets("Settings").ComboBox1.List = Split(Left2Use, ",")
   
   End If
   If IDNum <> 2 Then
      UsedList = UL2
      Left2Use = " "  ' Space
      For i = 0 To UBound(FullArray)
         iTxt = Trim("" & i + 1)
         If Not (InStr(1, UsedList, iTxt) > 0) Then
            ' Not Already Used - Add it to Left2Use
            Left2Use = Left2Use & "," & iTxt
         End If
      Next i
      Worksheets("Settings").ComboBox2.List = Split(Left2Use, ",")
   End If
End Sub
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
First thought, you are trying to programically change the control, yet you have entered the list/source using the controls properties window.
 
Upvote 0
First thought, you are trying to programically change the control, yet you have entered the list/source using the controls properties window.

I'm not really sure what to do to resolve this. also tried getting the list from cells.
 
Upvote 0
C
As @davesexcel says, just remove the rowsource that you’ve set in the ComboBox property window. You can’t use rowsource and list

Could you please tell me which code i need to remove?

The property window you are talking about, is it the "properties" when I right click the ActiveX Control ComboBox?

Thanks
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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