PDA

View Full Version : Error when trying to use COMBO BOXES PADLOCK



marreco
12-27-2012, 08:48 PM
Hi
I need your help again, I'm doing the project created two comboboxes padlocks, where one depends on the other, but this error message appearing.

time error '-2147467259 (80004005)

unspecified error

I used this code:

Private Sub ComboBox7_Change()
ComboBox7 = UCase(ComboBox7)
Call CarregaCargos(Me.ComboBox7.List(Me.ComboBox7.ListI ndex))
End Sub

Private Sub UserForm_Initialize()
Call CarregaGrupos
End Sub

Private Sub CarregaGrupos()
Dim linha As Integer, coluna As Integer
linha = 2
coluna = 1
Me.ComboBox7.Clear
With Sheets("G_Cargos")
Do While Not IsEmpty(.Cells(linha, coluna))
Me.ComboBox7.AddItem .Cells(linha, coluna).Value
linha = linha + 1
Loop
End With
End Sub

Private Sub CarregaCargos(ByVal Cargos As String)
Dim linha As Integer, colunaCargos As Integer, colunaGrupos As Integer
linha = 2
colunaCargos = 1
colunaGrupos = 2
Me.ComboBox8.Clear
With Sheets("Cargos")
Do While Not IsEmpty(.Cells(linha, colunaCargos))
If .Cells(linha, colunaGrupos).Value = G_Cargos Then
Me.ComboBox8.AddItem .Cells(linha, colunaCargos).Value
End If
linha = linha + 1
Loop
End With
End Sub

My file in:
Download ErroComboBox.xlsm from Sendspace.com - send big files the easy way (http://www.sendspace.com/file/m2z15n)

Thank you!!

Admin
12-27-2012, 09:56 PM
You are using RowSource property of combobox to list the values. So don't need to loop and add the items. Otherwise just remove the namedrange from the rowsource property of respective comboboxes. Also check your sheet names.

marreco
12-28-2012, 04:15 AM
Hi.
I followed your suggestion and it worked, thank you!!
problem solved!